八叶草

学习资料记录

__super - 本类的基类

来源:http://blog.sina.com.cn/s/blog_498c7cd50100nwnz.html


Visual C++ 8中的__super关键字


工作中看到别人的代码有__super::SetWindowSize()这样的代码,查询了一下备忘在这里。

Visual Studio 2005中新增了__super关键字,它代表本类的基类,因此可以像下面这样使用:

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

它还可以配合using语句使用,比如using __super::type_define;这样的。

posted on 2010-12-23 20:48 八叶草 阅读(1216) 评论(0)  编辑 收藏 引用 所属分类: VCIDE


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理