#include <iostream>
#include <cstdint>
using namespace std;
// your code here :- declare enum class ErrorCode
// ErrorCode has 4 values of type uint8_t --> None, Timeout, Overflow and Invalid
enum class ErrorCode : uint8_t {
None = 0,
Timeout = 1,
Overflow = 2,
Invalid = 3
};
// define a function that returns the string of input error code
const char* toString(ErrorCode e) {
switch (e) {
case ErrorCode::None: return "None";
case ErrorCode::Timeout: return "Timeout";
case ErrorCode::Overflow: return "Overflow";
case ErrorCode::Invalid: return "Invalid";
default: return "Unknown";
}
}
int main() {
int x;
cin >> x;
ErrorCode e = static_cast<ErrorCode>(x);
cout << toString(e);
return 0;
}
Input
0
Expected Output
None