Posted in All Posts, Semester 3

Sem 3 – OOCP Unit 2 Programs

OOCP – Object Oriented Concepts & Programming

Unit 2 – Dynamic Memory Management, Constructor & Destructor, Inheritance

1. Using friend function find the maximum number from given two numbers from two different classes. Write all necessary functions and constructors for the program.
Download | View Code

2. Using a friend function, find the average of three numbers from three different classes. Write all necessary member functions and constructor for the classes.
Download | View Code

3. Define currency class which contains rupees and paisa as data members. Write a friend function named AddCurrency ( ) which add 2 different Currency objects and returns a Currency object. Write parameterized constructor to initialize the values and use appropriate functions to get the details from the user and display it.
Download | View Code

4. Create Calendar class with day, month and year as data members. Include default and parameterized constructors to initialize a Calendar object with a valid date value. Define a function AddDays to add days to the Calendar object. Define a display function to show data in “dd/mm/yyyy” format.
Download | View Code

5. Create a class named ‘String’ with one data member of type char *, which stores a string. Include default, parameterized and copy constructor to initialize the data member. Write a program to test this class.
Download | View Code

6. Write a base class named Employee and derive classes Male employee and Female Employee from it. Every employee has an id, name and a scale of salary. Make a function ComputePay (in hours) to compute the weekly payment of every employee. A male employee is paid on the number of days and hours he works. The female employee gets paid the wages for 40 hours a week, no matter what the actual hours are. Test this program to calculate the pay of employee.
Download | View Code

7. Create a class called scheme with scheme_id, scheme_name, outgoing_rate, and message_charge. Derive customer class from scheme and include cust_id, name and mobile_no data. Define necessary functions to read and display data. Create a menu driven program to read call and message information for a customer and display the detail bill.
Download | View Code

8. Write a program with use of inheritance: Define a class publisher that stores the name of the title. Derive two classes book and tape, which inherit publisher. Book class contains member data called page no and tape class contain time for playing. Define functions in the appropriate classes to get and print the details.
Download | View Code

9. Create a class account that stores customer name, account no, types of account. From this derive classes cur_acc and sav_acc to include necessary member function to do the following:
• Accepts deposit from customer and update balance
• Compute and Deposit interest
• Permit withdrawal and Update balance.
Download | View Code

10. Write a base class named Employee and derive classes Male employee and Female Employee from it. Every employee has an id, name and a scale of salary. Make a function ComputePay (in hours) to compute the weekly payment of every employee. A male employee is paid on the number of days and hours he works. The female employee gets paid the wages for 40 hours a week, no matter what the actual hours are. Test this program to calculate the pay of employee.
Download | View Code

Download All

I hope that you found this article to be helpful.
Please share your thoughts in the Comments Section.

If you liked this article, then please like our Facebook page.

Suggested Reading

Comments