码迷,mamicode.com
首页 > 其他好文 > 详细

__super

时间:2015-12-30 19:32:17      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:

__super::member_function();
        The __super keyword allows you to explicitly state that you are calling a base-class implementation for a function that you are overriding. All accessible base-class methods are considered during the overload resolution phase, and the function that provides the best match is the one that is called.

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

int main() {
}

这样子成员函数能够调用父的成员函数




__super

标签:

原文地址:http://www.cnblogs.com/hrhguanli/p/5089570.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!