When an object's static type is used to associate it with a member function, this is known as static binding (understand the type of its class).
When a pointer or reference is associated with a member function based on the dynamic type of the object, this is known as dynamic binding (understand the instance of the variable at runtime).
Before continuing, keep in mind that dynamic binding only works with pointers, references, and virtual functions for the base class.
Because everything needed to call the function is known at compile time, the first call is a static binding (also known as early binding).
Derived1 d1(1, 10);
d1.display_data();
You already know that the d1 instance is a Derived1 automatic variable, and that it will call the Derived1::display data method ().
The first condition is incorrect: d1 is neither a pointer nor a reference.
The second condition isn't acceptable:
There is no virtual Derived1::display data.
The second call is for
...READ MORE
Jun 7, 2022
in C++
by
Damon
• 4,960 points
•
694 views