Your task is to declare a scoped enum class named ErrorCode with the following explicit numeric values:
enum class
ErrorCode
None = 0
Timeout = 1
Overflow = 2
Invalid = 3
The value ErrorCode::Invalid represents an explicit error state.
ErrorCode::Invalid
Implement a function:
const char* toString(ErrorCode e);
that returns the corresponding string:
"None"
"Timeout"
"Overflow"
"Invalid"
The program will read an integer from standard input and convert it to an ErrorCode as follows:
Finally, print the string representation of the resulting ErrorCode.
Example 1
Input:
0
Output:
None
Example 2
2
Overflow
Example 3
3
Invalid
Test Cases
Test Results
Input
Expected Output