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 / suchi
It depends the pointer points to the object of which class.
If the pointer points to Class A, then the method defined
in class A will be called, and if the pointer points to
class B, then the method defined in class B will be called.
| Is This Answer Correct ? | 2 Yes | 6 No |
Post New Answer View All Answers
What is encapsulation in ict?
What is destructor give example?
What is abstraction in oops?
What is polymorphism and example?
What are properties in oop?
#include
What is polymorphism and why is it important?
What are the three parts of a simple empty class?
Can we define a class within the interface?
What is abstract class in oop?
i got a backdoor offer in process global,Bangalore..Can i work with it?
just right the logic of it 1--> If few people are electing then every time ur candidate should win 2--> arrange books in box, if box carry weight == books weight then take another box..... find the no of box required.
What is static modifier?
What is interface? When and where is it used?
What polymorphism means?