eclare a class called item having data members item_code, item_name, cost and discount. Derive two classes from class item, namely employee and customer. The class employee has data members like employee_code, employee_name and amount. The class customer has data members like customer_name and amount. Define following functions for - initializing data members. - displaying the values of data members. - computing amount to be paid for a purchased item. Also define function main to create objects of both derived classes and to show usage of above functions.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
Declare a class called item having data members item_code, item_name, cost and discount.
Derive two classes from class item, namely employee and customer. The class employee has data
members like employee_code, employee_name and amount. The class customer has data
members like customer_name and amount. Define following functions for - initializing data
members. - displaying the values of data members. - computing amount to be paid for a
purchased item. Also define function main to create objects of both derived classes and to show
usage of above functions.
Step by step
Solved in 4 steps with 6 images