IntelliSense: the object has type qualifiers that are not compatible with the member function

getName is not const, getScore is not const, but print is. Make the first two const like print. You cannot call a non-const method with a const object. Since your Person objects are direct members of your other class and since you are in a const method they are considered const.

In general you should consider every method you write and declare it const if that’s what it is. Simple getters like getScore and getName should always be const.

Leave a Comment