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. |