I was following the course and came up with the following solution:
// repeat input to the player
void PlayGame()
{
constexpr int NUMBER_OF_TURNS = 5;
for (int count = 1; count <= NUMBER_OF_TURNS; count++)
{
cout << "The word you typed was: " << GetGuess() << endl << endl;
}
}
I’m calling the function GetGuess() while printing instead of declaring it to Guess like in the video. Is this also a right way of doing it, or will this be too confusing to read?
I think it’s fine if the only thing you’re doing is printing it out. Once you move on to doing other things with the guess, such as verifying if the guess is valid, you’ll need to move it.
But you understand what’s happening, and can see how things can be rewritten to have the same meaning, and that’s good.