Conditional expression of type 'void' is illegal ???

I am getting this errors when i compile this code and do not know how to fix it.

errors .... conditional expression of type 'void' is illegal line 271 //sixth line from the bottom



void drawCards(){...}
void displayCards(){...}
void statistics(){...}

void continueBattle() //tests whether a user wants to continue the battle or not
{ /*interaction */
string choice; // define variable in this section
do
{
cout<<"\n Another battle (enter: Y/N) ? ";
cin >> choice;
cout << choice << endl;
if (choice == "Y" || choice == "y") //user can enter Y or y.
{
system("cls");
}
else if (choice == "N" || choice == "n") //user can enter N or n.
{
exit(0);
}
else
{ // error message if user does not enter Y or N.
cout<<" Invalid input. Enter only 'Y' or 'N' please."<<endl;
}
} // loops to check for invalid input
while(choice != "Y" && choice != "y" && choice != "N" && choice != "n");
}

int main( )

{unsigned short face1 = 0, face2 = 0,
totalbattlesnumber=0, youwonnumber=0, tienumber=0;
char pic1, pic2;


//preparation(); // include operations no need to repeat

do
{
drawCards (face1=0, pic1, face2=0, pic2);
displayCards (face1=0, pic1, face2=0, pic2);
statistics (face1=0, face2=0, totalbattlesnumber=0, youwonnumber=0 ,tienumber=0);
} while (continueBattle());

cout<<"\n\n\t********** Game is over! **********\n\n";
return 0;
}
Last edited on
continueBattle() is a void. You can't use it in a conditional statement. It needs to return bool.

-Albatross
What does return bool mean. Is it just return 0; in the void continueBattle() ???
@masterrick

Perhaps you should learn how to actually code before you work on a game...
Thankful for the link
Topic archived. No new replies allowed.