Sun Studio 12 Update 1: C++ User's Guide

4.6 Using an enum Name as a Scope Qualifier

Because an enum declaration does not introduce a scope, an enum name cannot be used as a scope qualifier. For example, the following code is invalid.


enum E {e1, e2, e3};
int i = E::e1; // invalid: E is not a scope name

To compile this invalid code, use the -features=extensions option. The -features=extensions option instructs the compiler to ignore a scope qualifier if it is the name of an enum type.

To make the code valid, remove the invalid qualifier E::.


Note –

Use of this option increases the possibility of typographical errors yielding incorrect programs that compile without error messages.