__super

作用:

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

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


猜你喜欢

转载自blog.csdn.net/yufanghu/article/details/53318144