lakshmen
lakshmen

Reputation: 29064

Dynamic binding of virtual functions in C++

Suppose there is a derived class with a redefined function called print. Now I am accessing the derived class object using a base class pointer p.

Example 1.print() is a virtual function.

p->print() is called.This prints the derived class functionality at dynamic binding.

Example 2. print() is not a virtual function

p->print() is called. This prints the base class functionality. But my question is whether this is static binding or still dynamic binding?

Upvotes: 0

Views: 388

Answers (1)

David Schwartz
David Schwartz

Reputation: 182769

It would generally be considered static binding because which function is called is known and fully determined at compile time.

Upvotes: 4

Related Questions