__super

来源:互联网 发布:范玮琪形婚 知乎 编辑:程序博客网 时间:2024/06/11 05:38

作用:

在重载决策阶段将考虑所有可访问的基类方法,可提供最佳匹配项的函数就是调用的函数。

__super 只能在成员函数体内显示。

__super 不能与声明一起使用。 


// deriv_super.cpp  // compile with: /c  struct B1 {     void mf(int) {}  };    struct B2 {     void mf(short) {}       void mf(char) {}  };    struct D : B1, B2 {     void mf(short) {        __super::mf(1);   // Calls B1::mf(int)        __super::mf('s');   // Calls B2::mf(char)     }  };  


0 0
原创粉丝点击