Initializing a derived class enum with an (unlisted) base class enum of the same name
The following code (also on ideone ) looks like it shouldn't compile, but it works on MSVC 2008 and GCC 4.8.2
#include<iostream>
struct Base
{
enum State { ON = 11 , OFF = 22 , STANDBY = 33 };
};
struct Derived : Base
{
enum State { ON = ON , OFF = OFF }; // Huh?
};
int main()
{
std::cout << Derived::ON << std::endl;
}
Does it meet the standard?
+3
source to share