• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Error Handling with Enum Help.

CesarZ

Well-Known Member
Joined
Sep 20, 2012
Messages
269
Solutions
4
Reaction score
63
How can i apply this error handling code in adding() function?I just want to see how you guys would set it up.
if you have another function you want to add as an example instead of adding() add it. it's just for learning purposes.
i want to see different ways from people.
Thanks.


C++:
    enum class Error {
        SUCCESS,
        FAIL,
    };

    void errorMessages(Error type) {
        switch (type) {
        case Error::SUCCESS: std::cout << "Success" << std::endl;
            break;
        case Error::FAIL:std::cout << "Fail" << std::endl;
            break;
        default:
            std::cout << "Error in the code" << std::endl;
        }
    }
//fucntion to test it\/
int adding(int x, int y){
    sum = x + y;
    return sum;
}

int main()
{

    adding(4,4);
 
    return 0;
}
 
Back
Top