You are on page 1of 2

LAB QUESTIONS

1.Friend function

a. Create a class Number with an integer data member. Find the cube the number using friend
function.

b. Create a class Array with an integer array as its data member. Multiply the Array object with a
constant using friend function.

2. Operator overloading

a. Write a program to add two complex numbers by overloading operator +

b. Create a class Date with data members month, date and year. Create a Date object and find the
previous date by overloading unary operator - .

3. Inheritance

a. Implement the following relation. Find the grade and display all details of a student.

Student

Marks

Result

b. Implement the following relation. Parent classes only have member functions. Calculate the area
and perimeter of the Rectangle object and display.

Area Perimeter

Rectangle

c. Implement the following relation, calculate the salary of faculty and office staff and display all
details.

Salary of faculty =1000*hrs worked Salary of office staff =500*hrs worked.

Employee

Faculty Staff

4.Pointer to an Object

Create a class Rational with two data members to represent numerator(p) and denominator(q). Use
object pointer to call member functions to read and display the object in p/q form.
5. Virtual functions

Create a class Polygon with virtual functions to calculate area. Derive two classes Triangle and Square
from polygon. Read the dimensions and calculate the area of rectangle and triangle.

6. Files

a. Create a two text files personal.txt and professional.txt. Write personal details name, age and
address and professional details job and salary in respective files. Read from files and display in a neat
format.

b. Create a class Product with data members product name and price. Create an object and write
the object into a binary file, read from the file and display.

NOTE: The class details like data members and member functions are not specified in some
questions. They are already given in the lab. The 5 th question is virtual functions, not abstract class.

You might also like