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
Why we use #include conio h in c++?
What is namespace & why it is used in c++?
When should I use unitbuf flag?
Can create new c++ operators?
What are the types of pointer?
Can I learn c++ as my first language?
Why c++ is called oop?
What is copy constructor? Can we make copy constructor private in c++?
What's the "software peter principleā?
What is the role of C++ shorthand's?
Why is c++ not purely object oriented?
What is flag in computer?
Explain differences between new() and delete()?
Explain about vectors in c ++?
Define the operators that can be used with a pointer.