开发者

Invoke function within class method from outside the class with name the same like one method in class has

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
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜