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
Is c++ a good beginners programming language?
What is conditions when using boolean operators?
Explain the isa and hasa class relationships.
Explain differences between new() and delete()?
What is a constructor in c++ with example?
How to demonstrate the use of a variable?
What is the advantage of an external iterator.
What is null and void pointer?
What is ctime c++?
Explain shallow copy?
Explain what are single and multiple inheritances in c++?
Does c++ have foreach?
Is c++ a software?
Will a C compiler always compile C++ code a) Yes b) No c) Only optimized compilers
Which software is used for c++ programming?