From questions such as this and this, I was under the impression that inheriting from a primitive type would cause a compiler error. However, the following code compiles and produces expected output on Ideone.
#include <iostream>
enum class Test : unsigned short int
{
TEST, TEST2, TEST3, TEST4
};
int main() {
// your code goes here
Test ans = Test::TEST3;
if(ans == Test::TEST3)
{
std::cout << "Here" << std::endl;
}
return 0;
}
Does the fact that the class
is also an enum
change the answers in the first two Q&A's? Is this well-defined behavior by the standard?