In C++ any referenced non-built-in name must have been declared somewhere earlier.
It might appear that this rule has an exception for class definitions, because the following works fine:
struct S
{
void foo() { cout << x_ << endl; }
int x_;
S(): x_( 42 ) {}
};
However, the rule about declaration-before-use applies to the transformed code
struct S
{
inline void foo();
int x_;
inline S();
};
void S::foo() { cout << x_ << endl; }
S::S() : x_( 42 ) {}
which is what the compiler "proper" sees. And here there is no use of anything that hasn't already been declared.
The proper C++03 solution to your problem is to define the enumeration type before its first use. With C++11 you can alternatively forward-declare it, but then an underlying type must be specified,
C++11 §7.2/3:
“An opaque-enum-declaration is either a redeclaration of an enumeration in the current scope or a declaration
of a new enumeration. [Note: An enumeration declared by an opaque-enum-declaration has fixed underlying
type and is a complete type. The list of enumerators can be provided in a later redeclaration with an enum-
specifier. —end note ] A scoped enumeration shall not be later redeclared as unscoped or with a different
underlying type. An unscoped enumeration shall not be later redeclared as scoped and each redeclaration
shall include an enum-base specifying the same underlying type as in the original declaration.”