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


Please Help Members By Posting Answers For Below Questions

What is oops in programming?

558


What is multilevel inheritance in oop?

547


What is the highest level of cohesion?

566


What are the two different types of polymorphism?

666


What are objects in oop?

602






What does oop mean in snapchat?

675


What is difference between pop and oop?

597


What is inheritance write a program to show use of inheritance?

607


What is abstraction and encapsulation?

563


What are constructors in oop?

583


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?

1570


What is object in oops?

606


What is the real life example of polymorphism?

602


What is oops and its features?

576


What is a class oop?

588