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.
  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.
  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.
  4. Define a class student having all personal information. Also define all necessary function in a class. Find the student having maximum marks using a friend function.
  5. 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 afunction AddDays to add days to the Calendar object. Define a display function to show data in “dd/mm/yyyy” format.
  6. Create a class named ‘String’ with one data member of typechar *, which stores a string. Include default, parameterized and copy constructor to initialize the data member. Write a program to test this class.
  7. 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.