mercredi 1 avril 2015

If statement always executing even when the condition is false???

when it gets to this if statement, no matter what 'option' is inputted its always setting if(option == "y" || "Y") condition to true?





bool UserInterface::readInConfimDeletion() const
{
string option = "";
cout << "Are you sure you want to delete these transactions? Y/N ";
cin >> option;

if (option == "y" || "Y")
{
return true;
}
else if (option == "n" || "N")
{
return false;
}
else{
readInConfimDeletion();
}

}



Aucun commentaire:

Enregistrer un commentaire