Answer Posted / deepa balamurugan
If the both Base and the Derived class having the same
function then the Base class funtion should be declared as
virtual function. Then the C++ determines which function to
be called at the runtime based on the type of the object
pointed to by the Base pointer rather than the type of the
pointer.
As soon as the compiler reads the keyword virtual ,it will
create the vtable contains the address of the virtual
function inside that class and as soon as vtable is
created ,vptr is initialized to the proper vtable.
Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What is the arrow operator in c++?
which one is equivalent to multiplying by 2:Left shifting a number by 1 or Left shifting an unsigned int or char by 1?
What is the type of 'this' pointer?
Is string data type in c++?
Can we sort map in c++?
Which programming language should I learn first?
Can comments be nested?
Explain rtti.
What is the difference between #define debug 0 and #undef debug?
What is a null object in c++?
What is code reusability in c++?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
What is a dynamic binding in c++?
Do inline functions improve performance?
Which software is best for programming?