我有一个类叫做Person:
class Person { string name; long score; public: Person(string name="",long score=0); void setName(string name); void setscore(long score); string getName(); long getscore(); };
在另一个类中,我有这个方法:
void print() const { for (int i=0; i< nPlayers; i++) cout << "#" << i << ": " << people[i].getscore()//people is an array of person objects << " " << people[i].getName() << endl; }
这是人的宣言:
static const int size=8; Person people[size];
当我尝试编译它,我得到这个错误:
IntelliSense: the object has type qualifiers that are not compatible with the member function
在2人[i]的打印方式下的红线
我究竟做错了什么?