Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) enum class forward declaration

 

enum class forward declaration is a technique that has different meanings, depending on the standard used:

 

 

 

 

 

C++98 enum class forward declaration in the C++98 standard

 

enum class forward declaration is not supported in C++98.

 

 

 

 

 

C++11 enum class forward declaration in the C++11 standard

 

 

An enum class forward declaration is technique to do a forward declaration on an enum class:

 

//Forward declaration
enum class MyEnum;

//Definition
enum class MyEnum { a,b,c };

int main()
{
  const MyEnum x = MyEnum::a;
}

 

Technical note: the code shown did not compile using the G++ 4.4.5 compiler, which is supplied with the Qt Creator 2.0.0 IDE, but is expected to compile in G++ version 4.6 [1].

 

 

 

 

 

References

 

  1. GCC page about C++0x support

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict