C/C++ Arena

Step 4 of 9

const member functions

A member function marked const promises not to modify the object. Only const functions can be called on a const object or through a const&, so mark every method that just reads.

int hp() const { return hp_; }

Your turn: this doesn't compile because print_status takes a const Player& but calls methods that aren't marked const. Press Check to see the error, then fix the class (not the function).

Previous: Constructors Next: static members