Why do we need another bool?

I managed to get the result we were looking for without another bool. BullCowGame.
Why do we need another bool here, it seems to be bloating the code?
Thinking on this is it simply to make understanding the code clearer, ie AsktoPlayAgain is the question. bPlayAgain is the answer?

I’m wondering the same thing. It’s technically not even a ‘real’ bool because we’re already getting our true or false result from the original bool.

I got mine like this, cause I also didn’t see why we would repeat the intro:

int main()

{
PrintIntro();

do
{
	PlayGame();
} 
while (AskToPlayAgain() == 1);

return 0;

}

The only reason I can fathom that we’d need another bool is because we’ll be making changes later that will require that bool.

Maybe someone else can answer, I’m curious as well. I showed both snippets to some programmer friends, waiting on responses to see what they think.

Also I’ve given up trying to fix the “code” formatting on my post. You can see what I’m showing anyway.

You don’t is the answer, but I suspect it’s a sly way of introducing how you declare booleans in Unreals coding standard.

And BTW, both of you can change the do-while-loop to this:

do
{
	DoSomething();
} while (AskToPlayAgain());

You don’t need to have the “== 1” since AskToPlayAgain returns a bool.
In your code you’re effectively just asking if 1 == 1 or 0 == 1, which will give the correct result, but it’s not needed.

Privacy & Terms