So I was doing the challenge and came up with this code :
int main()
{
do
{
PrintIntro();
PlayGame();
} while (AskToPlayAgain());
return 0; //exit application
}
I was quite surprised watching the rest of the video and seeing we need to add another boolean, is there any downside for what I did? Testing the programs there seems to be no problems, but maybe for future coding?
I did the same. Can some confirm that’s ok? I was quite suprised that it worked actually. Didn’t think that function will run normally when put into the condition of a loop.
Yes that is what I decided to go with because as the program is reading top down, that called function still has to be evaluated to either true or false before reaching the while part of the condition. However, good practice may go against it.
Yup same. The additional bool variable is eventually getting fed by the AskToPlayAgain function anyways. I thought this would be easier. So even i’m not sure if that was done as good coding practice or to add more context.