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 oops in programming?
What is multilevel inheritance in oop?
What is the highest level of cohesion?
What are the two different types of polymorphism?
What are objects in oop?
What does oop mean in snapchat?
What is difference between pop and oop?
What is inheritance write a program to show use of inheritance?
What is abstraction and encapsulation?
What are constructors in oop?
IS IT NECESSARY TO INITIALIZE VARIABLE? WHAT IF THE INSTANCE VARIABLE IS DECLARED final ? IS IT NECESSARY TO INITIALIZE THE final VARIABLE AT THE TIME OF THEIR DECLARATION?
What is object in oops?
What is the real life example of polymorphism?
What is oops and its features?
What is a class oop?