Assignment 6 Polymorphism Arid
Assignment 6 Polymorphism Arid
What is Polymorphism:
The word polymorphism means having many forms. In simple words, we can define
polymorphism as the ability of a message to be displayed in more than one form. Real life
example of polymorphism, a person at the same time can have different characteristic. Like a
man at the same time is a father, a husband, an employee. So, the same person poses different
behavior in different situations. This is called polymorphism. Polymorphism is considered as one
of the important features of Object-Oriented Programming.
Types of Polymorphism:
Task 1:
A class named Desktop inherits Computer class and adds fields representing
A class named Laptop inherits Computer class and adds fields representing
Write a main() function that instantiates objects of derived classes to access respective show()
function using dynamic binding.
Task 2:
Task 3:
Consider a class named Calculator with typical four specific functionalities i.e. addition,
subtraction, multiplication, and division. Implement these functionalities as four functions with
two parameters. It is also required to overload all these functions for int and double data types.
In the main function, create an object of class Calculator and invoke its member functions while
passing parameters of int and double type.