Alex Rivera | Logout

A 'using' declaration with an enum

Asked 2009-01-13T07:16:46.303
11

A using declaration does not seem to work with an enum type:

class Sample{
    public:
        enum Colour {RED, BLUE, GREEN};
}

using Sample::Colour;

does not work!

Do we need to add a using declaration for every enumerators of enum type? Like below:

using sample::Colour::RED;
Edit
Report

1 Answer

5

C++ Standard, 7.3.3.1:

The member name specified in a using-declaration is declared in the declarative region in which the using-declaration appears. [ Note: only the specified name is so declared; specifying an enumeration name in a using-declaration does not declare its enumerators in the using-declaration’s declarative region. —end note ]

answered 2009-01-13T07:28:42.847

Your Answer