#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,