mardi 12 novembre 2019

How to define the value of other invalid input in this "if block" for converting string to object in c++?

I am trying to convert string to object in the following piece of code. How can I set the value of any other unrelated invalid input?

object stringToObject(string input){
    if (input == "rock")
        return object::rock;
    else if (input == "paper")
        return object::paper;
    else if (input == "scisors")
        return object::scissors;
}

Aucun commentaire:

Enregistrer un commentaire