A rhetorical question: how would you expect the compiler to know whether class Manager::TagManager
is a declaration of class TagManager
in namespace Manager
or a declaration of nested class TagManager
in enclosing class Manager
? The compiler never heard about Manager
before. It has no idea whether it is a class or a namespace. This is what the compiler is trying to tell you by that error message. It actually assumes that Manager
is a class type (not a namespace), which has not been defined.
However, even if it knew what Manager
was, it still wouldn't work. In C++ qualified names like Name1::Name2
can only be used to refer to existing (i.e. already declared) entities. You cannot use qualified names to declare new entities.
That means that a forward declaration of an entity that belongs to a namespace can only be done by reopening that namespace. A forward declaration of an entity that is nested into a class can only be done inside the definition of the enclosing class.
With entities in namespaces it is relatively easy, since you can reopen namespaces as many times as you want. With nested entities in classes you get only one chance.