In my opinion, the best (admittedly, indirect) solution is to use composition rather than inheritance:
class A { enum B { foo, bar }; std::vector<B> bs; };
If for some reason you need (or really want to) use private inheritance to insert a vector into your object, then the type must be defined before the class in the namespace scope, since types cannot be used before they are declared. If they are not accessible to users of the class, and you do not want to pollute the namespace containing your class, then you can put them in the namespace to indicate that they are implementation details:
namespace details { enum B { foo, bar }; } class A : std::vector<details::B> { typedef details::BB;
Mike seymour
source share