suppose A is a base class and B is the derved class. Both
have a method foo which is defined as a virtual method in
the base class. You have a pointer of classs B and you
typecast it to A. Now when you call pointer->foo, which
method gets called?
The next part of the question is, how does the compiler
know which method to call?
Answer Posted / nm
The answer is that B->foo gets calle, and why ? I found a
good explanation of that here:
http://en.wikipedia.org/wiki/Virtual_table
| Is This Answer Correct ? | 3 Yes | 1 No |
Post New Answer View All Answers
What is a class oop?
to find out the minimum of two integer number of two different classes using friend function
i=20;k=0;
for(j=1;k-i;k+=j<10?4:3)
{
cout< What are the 5 oop principles? What is object in oop? What is difference between oop and pop? Can destructor be overloaded? What is inheritance in simple words? What are the types of abstraction? What are main features of oop? What are oops methods? What are the benefits of oop? Give an example where we have to specifically use C programming language and C++ programming language cannot be used? What is the diamond problem in inheritance? What is property in oops?