You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Good example is a method virtual int getNumber() = 0; from class DynamicObject. It, moreover, should be made constant (like virtual int getNumber() const = 0;), because this method can be override in the descendant class. And if it is overridden in a way that changes the state of the object, it will break the semantics.
The same applies to the methods of the descendant class. For example int Player::getNumber(); should be int Player::getNumber() const;.
The text was updated successfully, but these errors were encountered:
bogdasar1985
changed the title
Methods that do not change the state of an object should be constant.
Methods that do not change the state of an object should be const.
Apr 4, 2021
Good example is a method
virtual int getNumber() = 0;
fromclass DynamicObject
. It, moreover, should be made constant (likevirtual int getNumber() const = 0;
), because this method can be override in the descendant class. And if it is overridden in a way that changes the state of the object, it will break the semantics.The same applies to the methods of the descendant class. For example
int Player::getNumber();
should beint Player::getNumber() const;
.The text was updated successfully, but these errors were encountered: