Adel Benhamida
Adel Benhamida

Reputation: 49

A very simple enum class error in C++

That's my code :

enum class MyEnum
{
    EnumValue1,
    EnumValue2 = 10,
    EnumValue3
};
int main()
{
    MyEnum value1 = MyEnum::EnumValue1;
    return 0;
}

when i compile this code i get an error code

error: 'MyEnum' is not a class or namespace

what's wrong is with it ?

Upvotes: 0

Views: 1623

Answers (1)

J-M. Gorius
J-M. Gorius

Reputation: 786

Simply tell g++ to follow the C++11 standard.

To do this in Code::Blocks, go to Project -> Build options and in the Compiler settings -> Compiler Flags tab, check "Have g++ follow the C++11 ISO C++ language standard" (make sure to change the behavior of g++ for the entire project, not only for the active target).

Upvotes: 1

Related Questions