我不明白这部分代码有什么问题:
struct aliance {
...
void setFirstTeam(const team& _team) {
firstTeam = _team;
}
void setSecondTeam(const team& _team) {
secondTeam = _team;
}
}
QVector< aliance > _aliances;
...
_aliances.at(i).setFirstTeam(firstAlianceTeam);
_aliances.at(i).setSecondTeam(secondAlianceTeam);
我收到错误:
passing 'const aliance' as 'this' argument of 'void aliance::setFirstTeam(const team&)' discards qualifiers [-fpermissive]
passing 'const aliance' as 'this' argument of 'void aliance::setSecondTeam(const team&)' discards qualifiers [-fpermissive]
我已经至少重试了这两个函数的所有变体,const
无论有无。