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.
There are three ways to use
using
. One is for an entire namespace, one is for particular things in a namespace, and one is for a derived class saying it doesn't want to hide something declared/defined in a base class. You can use the second of those:Unfortunately this isn't working for you (due to the ambiguity of the namespace and the class having the same name). Combining this type of using with a previous answer should get rid of the ambiguity:
But once you've renamed the namespace, you really don't need the
using
statement (as long as you're comfortable writing the (shortened) namespace every time you use the class:if you just want to use it as
Foo()
.I don't know what's ambiguous, but you can avoid all conflicts with other Foo functions like this:
It seems that you can't alias a class scope like this:
Maybe you could alias the function it self: