Say I have a class like this:
class A { public: class B { // ... }; static void f(); // ... };
I can refer to B
as A::B
and to f()
as A::f()
, but can I import B
and f()
into the global/current namespace? I tried
using A::B;
but that gave me a compilation error.
Here are two workarounds for your problem:
1) Class B:
typedef A::B B;
2) Function f():
inline void f() { A::f(); }
But think twice before using them.
Edit: In C++11 you can do auto f = A::f;
but this actually creates a pointer to a function and functions pointers cannot be inlined.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With