社区
VC.NET
帖子详情
在Derived class中 是否 一定要对 Base class 中的 Virtual function 重新定义?
JnBoor
2009-04-04 04:52:45
在Derived class中 是否 一定要对 Base class 中的 Virtual function 重新定义?
...全文
60
4
打赏
收藏
在Derived class中 是否 一定要对 Base class 中的 Virtual function 重新定义?
在Derived class中 是否 一定要对 Base class 中的 Virtual function 重新定义?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
4 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
JnBoor
2009-04-04
打赏
举报
回复
谢谢kkun_3yue3!我知道了,呵呵
JnBoor
2009-04-04
打赏
举报
回复
谢谢,知道了,呵呵
JnBoor
2009-04-04
打赏
举报
回复
谢谢,知道了,呵呵
kkun_3yue3
2009-04-04
打赏
举报
回复
不是一定的...
可以不重写
只有abstract声明的方法必须重写
EffectiveC++-条款09:绝不在构造和析构过程
中
调用
virtual
函数
## 一. 内容 1. 对于
base
-
derived
体系,
base
class
构造函数
一定
更早被调用,是的,
derived
class
对象
中
的
base
class
成分会在
derived
class
自身成分被构造之前构造妥当。 2. 这意味着在
base
class
里调用的
virtual
函数,尚未动态绑定
derived
class
的成分,
virtual
函数调用的是
base
class
里默认的实现。非正式的说法或者更加易懂:在
base
class
构造期间,
virtual
函数不是
virtual
函数。 3. 如果在b
How can a member
function
in my
derived
class
call the same
function
from its
base
class
?
Use
Base
::f(); Lets start with a simple case. When you call a non-
virtual
function
, the compiler obviously doesnt use the
virtual
-
function
mechanism. Instead it calls the
function
by name, using t
Virtual
Function
Virtual
Function
• A
virtual
function
is a
function
in a
base
class
that is declared using the keyword
virtual
. • Defining in a
base
class
a
virtual
function
, with another version in a
derived
class
, ...
多重继承下
Virtual
Function
的语意
在多重继承
中
支持
virtual
function
, 其复杂度围绕在第二个及后继的
base
class
es 上, 以及必须在执行期调整 this 指针这一点, 以以下的
class
体系为例:
class
Base
1 { public:
Base
1();
virtual
~
Base
1();
virtual
void SpeakClearly(); ...
Question 48: In C++, which of the following statements accurately describe a
base
class
destructor calling a
virtual
function
ov
A. The
base
class
destructor calls the
virtual
function
override of the
derived
class
through the vtable.
B. The
base
class
destructor cannot call the
virtual
function
override of the
derived
class
because the
derived
class
portion of th
VC.NET
7,540
社区成员
27,673
社区内容
发帖
与我相关
我的任务
VC.NET
.NET技术 VC.NET
复制链接
扫一扫
分享
社区描述
.NET技术 VC.NET
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章