0

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 ?

1 Answers1

1

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).

J-M. Gorius
  • 606
  • 4
  • 15
  • what u mean with (make sure to change the behavior of g++ for the entire project, not only for the active target) ?, can u explain ? – Adel Benhamida Jul 12 '17 at 13:41
  • When opening the project's *Build Options*, on the left hand side there is a tree where you can select *ProjectName*, *Debug* or *Release*. In order for your modification to be global (and thus to be independant of the build target), you should select **ProjectName** in the tree before changing anything. – J-M. Gorius Jul 12 '17 at 13:44
  • thank you, I checked "Have g++ follow the C++11 ISO C++ language standard" in Project -> ....... and also checked it in Settings -> Compiler Settings ..... , i had to check it in both places to made it works . – Adel Benhamida Jul 12 '17 at 13:46
  • 2
    Also consider installing mingw-w64 (for some reason, C::B still distributes the old defunct mingw) – M.M Jul 12 '17 at 13:50
  • @AdelBenhamida I'm glad it helped. – J-M. Gorius Jul 12 '17 at 13:53