I have a base class with 1 virtual function
class Base
{
public:
virtual void print() {
cout<<"IN BASE\n";
}
}
Now I create its object using
Base b
and Call
b.print();
Is this dynamic binding, as the “Base” class contains 1 virtual function and its VTable is created..
In the same context where the object is created, the compiler does not need to use virtual dispatch as it knows the exact type. But that is unrelated to the number of virtual functions (and yes, as long as there is at least one, the compiler will generate a vtable and store a vptr in your object).