The following code (also on ideone) looks like it shouldn't compile but it does 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;
}
Is it standard compliant?
enum State { ON = ON , OFF = OFF }; // Huh?
^^
At this point derived re-definition is not complete, so ON used would be from Base.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With