Removing the side effect

I have a problem with making "cout << Your guess was: " etc. an extra function. The final program wants me to type in every answer twice:

This is the important part of my written code, HERE is the full version on GitHub.

I know that it doesn’t have to be an extra function and I will just use “the solution” to keep going but I want to unterstand what I did wrong.

It seems as though your issue is with your for loop. You are calling your GetGuess() method, but you are also calling it in your RepeatGuess() method. You are calling one right after another in your loop, so it is asking twice. I hope this helps.

1 Like

Thank you, you’re right.

I just deleted " = Get Guess()", now it works using only the simple decleration(?) “string Guess;”.

1 Like

Privacy & Terms