__super key word

来源: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 2012-06-15 09:27 刘伟 阅读(139) 评论(0)  编辑 收藏 引用 所属分类: C,C++


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


<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿

随笔分类

文章分类

文章档案

搜索

最新评论