The code bellow will give compile error on line enum en = A::en; but it describes what I want to do (to make nested enum of A to be nested enum of B as well).
#include <iostream>
using namespace std;
struct A
{
enum a_en{X = 0, Y = 1};
};
struct B
{
enum b_en = A::a_en; //syntax error
};
int main()
{
cout << B::X << endl;
return 0;
}
So the question is how can I do such thing in c++?
Put the enum in a base class that both A and B can inherit from.