I have a bool function with an if else statements inside it. The first 'if' returns 'false' and the else returns 'true'. I want to call this boolean function in an other function with a while loop inside it. I have tried several times and I made it work. However, when I call the function it return 'true' all the time. How can I fix that?
bool secretCheck(string P1_name, string P2_name, char secret){
secret = 'R', 'G', 'B', 'P', 'Y', 'M';
if (secret != 'R' && secret != 'G' && secret != 'B' && secret != 'P' && secret != 'Y' && secret != 'M' && secret > 4){
return false;
}
else {
return true;
}
}
void secretLoop(string P1_name, string P2_name, char secret){
while(!secretCheck(P1_name, P2_name, secret)){
cout << "Invalid secret!"<< endl;
cout << P1_name << ", please enter your secret: ";
cin >> secret;
}
if(secretCheck(P1_name, P2_name, secret)) {
cout << "Ok\n";
}
}