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
Define a constructor - what it is and how it might be called (2 methods)?
What is the difference between the compiler and the preprocessor?
What is public, protected, private in c++?
What is prototype for that c string function?
Which function should be used to free the memory allocated by calloc()?
Define a conversion constructor?
Explain about Garbage Collector?
what is data encapsulation in C++?
Does c++ have arraylist?
Implement stack operations with pointers with appropriate exception checks.
Explain virtual destructor?
Carry out conversion of one object of user-defined type to another?
What does it mean to declare a member variable as static?
How can we check whether the contents of two structure variables are same or not?
Why is main an int?