Alternative, Cleaner Way of Echoing Back Guess to Player

The return value can be printed directly, without any variable declaration. This is what I prefer, although it ultimately will be a matter of taste:

for (int i = 0; i < NUM_ALLOWED_GUESSES; ++i)
	// Get the guess and print it back to the player.
	cout << "Your guess is: " << GetGuess() << "\n";

The string is stored in a variable and not echoed directly because it is passed into functions you create later in the course. But if that were not the case, your way would indeed be cleaner and more efficient.

Good point, and I agree with you. Didn’t think of that. Appreciate the feedback.

Privacy & Terms