Home > Back-end >  The return statement is there are always prompt function to return a value
The return statement is there are always prompt function to return a value

Time:01-11

I small white one, just to learn something, try to weave a little game to play, the result is out of the question here, for the great god solve meowed


 
#include
#include
using namespace std;
Int menuForMethod (pet playerPet);//the menu function that returns a value
Int main () {... }
Int menuForMethod (pet playerPet)
{
int num;
Cout & lt; Cout & lt; <"* * * * * * * * * * * * menu options * * * * * * * * * * * *" & lt; Cout & lt; Cout & lt; <"1) open the store system" & lt; Cout & lt; <"2) forward to adventure!" Cout & lt; <"3) to examine their pet" & lt; Cout & lt; Cout & lt; <"* * * * * * * * * * * * menu options * * * * * * * * * * * *" & lt; Cout & lt; Cout & lt; <"Choice:" & lt; Cin & gt;> Num.
While (cin) fail () | | (num!=1 & amp; & Num!=2 & amp; & Num!=3)) {//inspection input
Cin. The clear ();
Cin. Ignore ();
Cout & lt; <"Input error, please input again" & lt; Cin & gt;> Num.
}
If (num==1 | | num==2) {
return num;
} else {
Prt_playerPet (playerPet);
//it is no good added return here
}
//it is no good added return here
}



Is this menuForMethod function, the compiler is always an error, says menuForMethod () needs to return values, can function return is there, and I add you can return the place is added, it is no use,
The great god solution, urgent!!

CodePudding user response:

The menu function to the void, not int,
  • Related