Access enumeration values ​​from another class

In my project, I have an enumeration defined in a class that is used throughout this class. During refactoring, this enumeration was moved to another class. So I just typedefedited it in my original class, for example:

class A {
public:
  enum E {e1, e2};
};
class B {
public:
  typedef A::E E;
};

Now, variable definitions, return values, function parameters, etc. work great. Only when I want to access enum values ​​inside my second class will I still have to qualify them with the environment class name,
for exampleE e = A::e1;

Is there a way to avoid this, or do I need to copy it into each value of the enum values?

+5
2

, :

class A {
public:
  struct E { enum EnumType { e1, e2 } };
};
class B {
public:
  typedef A::E E;
};

E::EnumType E, .

+2

++ 11, .

0

All Articles