Using a class in a namespace with the same name?

c++, class, namespaces, symbols

Solution

I don't know what's ambiguous, but you can avoid all conflicts with other Foo functions like this:

namespace ALongNameToType {
    struct ALongNameToType {
        static void Foo();   
    };
}

typedef ALongNameToType::ALongNameToType Shortname;

int main() {
    Shortname::Foo();
}

Problem

I have to use an API provided by a DLL with a header like this ``` namespace ALongNameToType { class ALongNameToType { static void Foo(); } } ``` Is there a way to use ALongNameToType::ALongNameToType::Foo without having to type ALongNameToType::ALongNameToType each time? I tried using `using namespace ALongNameToType` but got ambiguous symbol errors in Visual Studio. Changing the namespace name or removing it gives me linker errors.

Original source

Related problems