Tuesday, June 26, 2007

Never define an inherited non virtual function

If mf is non virtual and Base and derived have their own version of this function then

D x;
B* pb = &x
D* pd = &x;
Pb->mf() & pd->mf() will call different functions.

References exhibit the same baffling behavior as pointers above. I don't really understand this ??

Things to remember:
Never redefine an inherited non virtual function


No comments: