由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - a question about overriding
相关主题
Overridden function will cause function shadow in C++, but not in Javaa new c++ intro book
为什么derived object没有vptr?哪位大侠有如下书籍的电子版,或者下载地址,多谢
The untold truth about C++[合集] 请牛人解释为啥C++ has stronger typing than C//bow
Question on C++ Access Control (protected)[合集] c++的dynamic_cast是如何实现的?
C++,大家觉得最值得买最想买最不后悔买的书是哪本?[合集] Stroustrup的新书
VB, C++初学者清推荐书籍/usr/bin/ld: Undefined symbols:
question about const referenceC++0x
c++ cast problem读Bjarne Stroustrup写得The C++ programming language 是不是经常有不知所谓的感觉。
相关话题的讨论汇总
话题: function话题: overriding话题: so话题: virtual话题: question
进入Programming版参与讨论
1 (共1页)
w*****j
发帖数: 49
1
I read a c++ book written by Stroustrup. He said that a virtual function has
to be redeclared exactly the same way to be overriden. So I wrote a
function that's not exactly the same as in the base class.(It doesn't have "
const") But when I call the function. It's still the function in the derived
calss being called. So does that mean the virtual function hasn't been
overridden? Or is there any other way to explain it?
N***m
发帖数: 4460
2
pls refer to name hiding

has
"
derived

【在 w*****j 的大作中提到】
: I read a c++ book written by Stroustrup. He said that a virtual function has
: to be redeclared exactly the same way to be overriden. So I wrote a
: function that's not exactly the same as in the base class.(It doesn't have "
: const") But when I call the function. It's still the function in the derived
: calss being called. So does that mean the virtual function hasn't been
: overridden? Or is there any other way to explain it?

z****e
发帖数: 2024
3
what you are doing is "overide with different interface", or "redefine".
all things will be fine except polymorphism.
1 (共1页)
进入Programming版参与讨论
相关主题
读Bjarne Stroustrup写得The C++ programming language 是不是经常有不知所谓的感觉。C++,大家觉得最值得买最想买最不后悔买的书是哪本?
Effective C++ 这破书!VB, C++初学者清推荐书籍
(zz)C++11新特性question about const reference
这么好的帖子没人转?c++ cast problem
Overridden function will cause function shadow in C++, but not in Javaa new c++ intro book
为什么derived object没有vptr?哪位大侠有如下书籍的电子版,或者下载地址,多谢
The untold truth about C++[合集] 请牛人解释为啥C++ has stronger typing than C//bow
Question on C++ Access Control (protected)[合集] c++的dynamic_cast是如何实现的?
相关话题的讨论汇总
话题: function话题: overriding话题: so话题: virtual话题: question