I've got construction of namespaces like this:

namespace one
     namespace two
         class SomeClass{...};

and when I try to use this class (without fully qualified name) in another file (also with nested namespaces) I'm getting errors. It doesn't even help if I place declaration of using this namespace in the file in which I'm intend to use this class. The only way I found is to use fully qalified names if there is more than one level of namespaces, but I hope that there is solution to this. Looking forward to your replays. Thank you.

Edited by mike_2000_17: Fixed formatting

8 Years
Discussion Span
Last Post by atch

Hmm. Hard to say without seeing code, really. You could always using namespace namespaceOne::namespaceTwo; if you wanted to hide the thing.


Please post the smallest compilable example of your problem. "I'm getting errors" doesn't really let us know what is going on.

My guess is you need to put "typename" in front of your nested qualifier:

typename namespaceOne::namespaceTwo::YourClass A;
//instead of
//namespaceOne::namespaceTwo::YourClass A;

The later is ambiguous - the compiler tries to call a function, so you have to make it clear that you, instead, want to declare a variable of that type.


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.