自从我们使用 STL 以来已经有很长时间了,因此我们将不胜感激。不知道我们在这里做错了什么......鉴于此,为什么这段代码会引发错误:
“你不能分配给 const 的变量”
struct person
{
int age;
bool verified;
string name
bool operator< (person const &p)
{
return (age < p.age);
}
};
multiset<person> msPerson;
multiset<person>::iterator pIt;
// add some persons
while (adding people)
{
Person p;
p.name=getNextName();
p.age=getNextAge();
msPerson.insert(p);
}
pIt = msPerson.begin();
// try to verify
pIt->verified = true; <---- **error here....**