Is there a simple way to invoke the function within some class method from outside the cla开发者_如何学Pythonss with name the same like one method in class has.
I have 3 different examples.
void a () { // outside the class
}
class A {
// example 1, the same names
void a() {
a (); // but the outside one,
}
// example 2, different list of arguments
void a(int x) {
a (); // but the outside one,
}
// example 1, different names
void b () {
a (); // but the outside one,
}
};
Thanks in advance
To reference a name outside the current class, use an empty namespace operator ::
.
void A::a()
{
::a (); // calls the outside one
}
精彩评论