Problem :
I have my class called MyPerson:
class MyPerson {
string myname;
long myscore;
public:
MyPerson(string myname="", long myscore=0);
void setMyName(string myname);
void setMyScore(long myscore);
string getMyName();
long getMyScore();
};
In other class, I have the below method:
void myprint() const {
for (int j=0; j< nMyPlayers; j++)
cout << "#" << j << ": " << people[j].getMyScore()//people is the array of the person objects
<< " " << people[j].getMyName() << endl;
}
This is my declaration of people:
static const int mysize=8;
MyPerson people[size];
But when I try to compile the code I face below error:
IntelliSense: the object has type qualifiers that are not compatible with the member function
with red lines under the the 2 people[j] in the print method
Am I doing something wrong here?