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 abstraction example?
Write a c++ program to display pass and fail for three student using static member function
What is the difference between abstraction and polymorphism?
What are the three main types of variables?
What are the components of marker interface?
What is the difference between procedural programming and oops?
Why do we use encapsulation in oops?
Can an interface inherit a class?
What is static modifier?
Why multiple inheritance is not possible?
write a programe to calculate the simple intrest and compund intrest using by function overlading
Why do we use class?
What is oops in simple words?
Why do we use class in oops?
Is html an oop?