VC++中的__super::
来自Microsoft的解释:
Microsoft Specific
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.
__super::member_function();
__super can only appear within the body of a member function.
With the introduction of attributes that inject code, your code might contain one or more base classes whose names you may not know but that contain methods that you wish to call.
Example
// deriv_super.cpp
struct B1 {
void mf(int) {
// ...
}
}; struct B2 {
void mf(short) {
// ...
} void mf(char) {
// ...
}
}; struct D : B1, B2 {
void mf(short) {
__super::mf(); // Calls B1::mf(int)
__super::mf('s'); // Calls B2::mf(char)
}
}; int main() {
}
END Microsoft Specific
中文意思:
__super是编译器关键词,是一个辅助工具,在多重继承和多级继承环境下很方便,当你需要调用基类成员时,不需要你记忆这个成员到底是哪个基类提供的,编译器会帮你找到正确的基类。如果存在二义性(比如有两个基类提供了相同名称的成员),编译器会报错,在错误信息中会指出有哪些基类具有此成员,此时你可以根据提示信息把__super修改成希望的基类。总之一句话——它帮你减少记忆负担。
最新文章
- Windows 64位下装Oracle 11g,PLSQL Developer的配置问题,数据库处显示为空白的解决方案
- 【Alpha版本】冲刺-Day8
- 当html标签不被识别时(不解析)不妨试试htmlspecialchars_decode();试试
- JSBinding+SharpKit / 脚本加密(JSC或Bytecode,参考cocos2d-js)
- TCP与UDP协议
- RemoteWebDriver管理
- IOS打开其他应用、以及被其他应用打开
- 奥运会订票系统c语言代写源码下载
- 当 IDENTITY_INSERT 设置为 OFF 时,不能为表中的标识列插入显式值。
- Struts1.x 环境搭建和技术准备(上)
- win7(iis7)无法加载运行CSS和图片的解决方法
- RunLoop总结:RunLoop的应用场景(三)
- java 中拿项目路径
- mongodb基类封装实例
- C++学习笔记52:查找
- ionic this.navCtrl.push()和this.navCtrl.pop()
- PAT 乙级 1005 继续(3n+1)猜想 (25) C++版
- JVM总结-虚拟机加载类
- OpenMPI源码剖析:网络通信原理(二) 如何选择网络协议?
- 了不起的Node.js--之三
热门文章
- Qt程序Release版出现 类似 QEventLoop: Cannot be used without QApplication 问题的终极解决方案
- elixir 关键字列表
- 行动学习方法----PARR
- srop实战
- 重装系统,打开VS进行程序调试运行的时候 Unable to find manifest signing certificate in the certificate store
- iphone精简教程
- 【眼见为实】自己动手实践理解数据库READ UNCOMMITED &;&; SERIALIZABLE
- [控件] LineAnimationView
- POST请求上传多张图片并携带参数
- 使用CAReplicatorLayer [1]