Possible const functions

I believe that isWon and isGuessStructured could also be const functions because they are just returning something about the game function rather than changing something about it.

Wonder why nobody replied to you just yet. So I’ll do it:
Yes, you’re right! Adding const to any method implies that the method (i.e. object’s function) does not change the state (variables) of the entire object (i.e. class instance).

Go ahead and make them const functions (make sure to do it both in .h and .cpp files!). Compiler should be happy about that change. Build your project and check! :slight_smile:

Now, to make it explicit, go back to one of your const functions and make it deliberately change one of the class variables. Your compiler should now complain, because you want to change the state of the game object. You won’t be able to compile (error) or run the game until you correct this.

Privacy & Terms