Answer the question
In order to leave comments, you need to log in
How to assign a pair?
Can you explain to me why this doesn't compile?
pair<const string, int> p1("x", 123);
pair<const string, int> p2("y", 321);
p1 = p2;
Answer the question
In order to leave comments, you need to log in
Your assignment does p1.first = p2.first
and p1.second = p2.second
. But you prevented assigning to p1.first
by declaring it as const
.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question