So I have this boolean that I just don’t understand
bool PlayAgain()
{
cout << "Do you want to play again? (y/n)? ";
string Response = “”;
getline(cin, Response);
return (Response[0] == ‘y’) || (Response[0] == ‘Y’);
}
So this boolean is returning y or Y, how does this correlate to true or 1?
Also,
int main()
{
bool bPlayAgain = false;
do
{
Intro();
PlayGame();
bPlayAgain = PlayAgain();
} while (bPlayAgain);
return 0;
I create this boolean bPlayAgain. This is set to the output of the PlayAgain Function. So if I am not mistaken this would change the bool equals to ‘y’. How does this while loop work?
Is a boolean set to true automaticall?