Suggested Const Functrions

I think that both IsGameWon() and CheckGuessValidity(std::string) functions could be const functions. The reason for this is that there name suggests that both functions are checking something, and then outputting a boolean for either a correct or incorrect answer.

If these functions are checking something, as their names suggest, then they should be only doing compares, and should not be changing any variables. Therefore, to ensure that the functions adhere to their names, they should be protected using const.

1 Like

Privacy & Terms