__super

Microsoft 专用

允许您显式说明要为正在重写的函数调用基类实现。

语法

__super::member_function();

备注

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

__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)
   }
};

结束 Microsoft 专用

另请参阅

关键字