17.5.3 Virtual methods
日期:2007年5月3日 作者: 查看:[大字体 中字体 小字体]-
When an instance method declaration includes a virtual modifier, that method
is said to be a virtual method.
When no virtual modifier is present, the method is said to be a non-virtual
method.
The implementation of a non-virtual method is invariant: The implementation
is the same whether the method is
invoked on an instance of the class in which it is declared or an instance
of a derived class. In contrast, the
implementation of a virtual method can be superseded by derived classes.
The process of superseding the
implementation of an inherited virtual method is known as overriding that
method (§17.5.4).
In a virtual method invocation, the run-time type of the instance for which
that invocation takes place determines
the actual method implementation to invoke. In a non-virtual method
invocation, the compile-time type of the
instance is the determining factor. In precise terms, when a method named N
is invoked with an argument list A
on an instance with a compile-time type C and a run-time type R (where R is
either C or a class derived from C),
the invocation is processed as follows:
? First, overload resolution is applied to C, N, and A, to select a
specific method M from the set of methods
declared in and inherited by C. This is described in §14.5.5.1.
? Then, if M is a non-virtual method, M is invoked.
? Otherwise, M is a virtual method, and the most derived implementation of
M with respect to R is invoked.
For every virtual method declared in or inherited by a class, there exists
a most derived implementation of the
method with respect to that class. The most derived implementation of a
virtual method M with respect to a class R
is determined as follows:
? - [1] [2] [3] 下一页
-
- 17.5.3 Virtual methods 相关文章:
- ·17.5.3 Virtual methods
- 17.5.3 Virtual methods 相关软件
- 特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作
- 者.文章版权归文章原始作者所有.对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转
- 载的文章有版权问题请联系编辑人员,我们尽快予以更正. 转载请注明来源:http://www.hackhome.com
上一篇:用J2ME开发企业级无线应用
精品推荐
热点TOP10
- ·图象处理中的边缘检测------canny算子
- ·EZ-USB 68013A开发指南
- ·数值计算程序大放送-特征值和特征向量
- ·ARM的嵌入式Linux移植体验之BootLoader
- ·Visual C++ ADO数据库编程入门
- ·智能手机Smartphone开发导语
- ·利用 wordXP 实现自动排班
- ·[分形]DLA团簇模型的摸拟
- ·DENX U-Boot及Linux使用手册
- ·Static和Final修饰类属性变量及初始化
- ·BPEL的异常管理
- ·看Vue 5 Esprit函数的节点与链接详情
- ·初学者全面接触学习jquery(译文)
- ·LinQ学习之旅 从整型数组中找出偶数
- ·Enterprise Library 快速入门
- ·CVS源代码库服务器建立和权限配置
- ·Visual FoxPro 9.0 SP2正式版下载
- ·VS2005控件的问题解决办法
- ·Cookie是什么?用法是怎样?与SESSION有什么区别?
- ·J2SE API读取Properties文件的六种方法
