Boolean Variable to Quit Game?

Quick question...

How can I use a boolean variable as a return at the end of a boolean function to quit a game?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
bool GetPlayerInput( string sPrompt, string sError, float &fResult, float fMin, float fMax)
{

	bool IsGameOver;
	
		do
		{

			cout << sPrompt;
			cin >> fResult;

			

			if( fResult == 0 )
				IsGameOver = false;

			if( fResult < fMin || fResult > fMax )
				cout << sError;
				
		} while( fResult < fMin || fResult > fMax);


		return IsGameOver;


}


I need to return a boolean value to exit the game if the player enters zero for the fResult or to continue the game if the player enters any non-zero number.
Last edited on
@LadyDustBunny

When you first declare bool IsGameOver;, you should initialize it to true, or use else IsGamerOver = true; after
1
2
if( fResult == 0 )
IsGameOver = false;
otherwise, what is the value of your return IsGameOver; ?
Topic archived. No new replies allowed.