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
Question: Write a program that prints a paycheck. Ask the program user for the name of the employee, the hourly rate, and the number of hours worked. If the number of hours exceeds 40, the employee is paid “time and a half”, that is, 150 percent of the hourly rate on the hours exceeding 40. Be sure to use stepwi se refine ment and break your solution into several functions. Use the int_name function to print the dollar amount of the check.
• What are the desirable attributes for memory managment?
What are the three parts of a simple empty class?
How do you achieve runtime polymorphism?
What is the difference between encapsulation and polymorphism?
What is polymorphism and why is it important?
Write a c++ program to display pass and fail for three student using static member function
Why do we use oop?
Why polymorphism is used in oops?
Are polymorphisms mutations?
write a program to find 2^n+1 ?
What are functions in oop?
What is abstraction with example?
What is interface? When and where is it used?
What does I oop mean?