一个开始

164 阅读1分钟

__super关键字

解释如下:

  1. 在包含多个基类的时候,__super可以自动找到正确的基类;
  2. 如果两个基类成员名相同时,编译会报错;
  3. __super不能using一起使用。

示例

struct A{
    void f(int){}
}
struct B{
    void f(short){}

    void f(char){}
}

struct D:A,B{
    void f(short){
        __super()::f(1);  //call void f(int)
        __super()::f('c'); //call void f(char)
    }
}