如何定义LogLevel变量l?
目前我有错误:
Error 3 error C2228: left of '.LogLevelDebug' must have class/struct/union
代码:
typedef enum LogLevel
{
LogLevelDebug = 0,
LogLevelError = 1,
LogLevelInfo = 2,
LogLevelTrace = 3,
} LogLevel;
int main ()
{
logLevel l = LogLevel.LogLevelDebug;
}
答案 0 :(得分:3)
在c++11中,它将是:
enum class LogLevel
{
LogLevelDebug = 0,
LogLevelError = 1,
LogLevelInfo = 2,
LogLevelTrace = 3,
};
int main ()
{
LogLevel l = LogLevel::LogLevelDebug;
}
在之前的C ++标准中:
enum LogLevel
{
LogLevelDebug = 0,
LogLevelError = 1,
LogLevelInfo = 2,
LogLevelTrace = 3,
};
int main ()
{
LogLevel l = LogLevelDebug;
}