Introduction to OOP: Chapter 12: Implications of Inheritance [next] [previous] [audio] [real] [text]

Rules for Member Function Binding

The rules for deciding what member function to execute are complicated because of the slicing problem.

1.
With variables that are declared normally, the binding of member function name to function body is based on the static type of the argument (regardless whether the function is declared virtual or not).

2.
With variables that are declared as references or pointers, the binding of the member function name to function body is based on the dynamic type if the function is declared as virtual, and the static type if not.
Intro OOP, Chapter 12, Slide 9