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 are the extraction and insertion operators in c++?
Is it possible to use a new for the reallocation of pointers ?
What are the four main data types?
What is pointer -to-members in C++? Give their syntax?
How do we implement inheritance in c++?
What is this pointer in c++?
What is the use of seekg in c++?
What is microsoft c++ redistributable 2013?
What is the use of turbo c++?
Explain the difference between overloading and overriding?
How can you quickly find the number of elements stored in a dynamic array?
Why is it necessary to use a reference in the argument to the copy constructor?
Is java the same as c++?
Does dev c++ support c++ 11?
What is a rooted hierarchy?