Is it legal?
class SomeClass {
public:
static void f();
};
using SomeClass::f;
Edit: I forgot to qualify function. Sorry.
No, it is not. The using keyword is used to bring one or all members from a namespace into the global namespace, so that they can be accessed without specifying the name of the namespace everytime we use the members.
In the using statement you have given, the name of the namespace is not provided. Even if you had provided SomeClass there with a statement like using SomeClass::f;
also, it won't work because SomeClass is not a namespace.
Hope this helps.
I think that using x;
is normally used inside a class to bring method names from a base class into scope to avoid hiding base class methods.
You might be thinking of using namespace name;
which only applies to namespaces.
You may be better off with a simple in-line function:
void f(){ SomeClass::f(); }
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