Lab 7 OOP 2A
Lab 7 OOP 2A
Lab Manual
Object Oriented Programming
Section BSCS 2A
Semester Spring 2022
Instructions
Make sure memory is deallocated properly
Make appropriate functions if you need them.
Task 01
Lamborghini is an international luxury sports car developer stationed in Italy. The company has a
reputation for producing cars that are extremely expensive, powerful and rare. Lamborghini has
developed a brand new model called the Diablo. The company produces a very limited numberof
Diablo’s each year. The company is producing the Diablo in only one colour called the “Hot Red”.
When the company has produced a Diablo, the car has a number of attributes like colour, cubic
capacity, number of seats, year of manufacture, engine number, frame number and owner name.
Out of these attributes the attributes that remain the same for all Diablo’s being produced are
colour, cubic capacity and number of seats.
Suppose you are working on a system specially designed for the Lamborghini Diablo. Follow the
instructions below for creating the class and objects:
Create default argument constructor.
Create an object named “obj1” and initialize the object.
Create a copy constructor that can copy all those attributes that remain the same for all
cars.
Create getter and setter functions to set and get the data of the data member
Generate another object named “obj2” that is created by copying only those attributes that
are the same from “obj1”.
Initialize the remaining attributes with values of your own.
Example input and output:
Task 02:
Example:
Task 03
Implement a class called Complex. The Complex class will have two data members:
int real; // The real part of complex number
int imaginary; // Imaginary part of the complex number.
You have to implement default constructor, overloaded constructor, copy constructor, destructor
and overload the operators +, - , <, >, ==,! =, prefix and postfix (addition and subtraction)
Sample Run:
Driver.cpp Output
int main()
{
Complex C1;
Complex C2(5,7); 9 + 13i
Complex C3(4,6); C1 != C2
C1 != C3
C2 IS GREATER
C1=C2+C3; C3 is smaller
if(C1!=C3)
cout<<"C1 != C3"<<endl;
else
cout<<"C1==C3"<<endl;
if(C2>C3)
cout<<"C2 IS GREATER"<<endl;
else
cout<<"C3 IS GREATER"<<endl;
if(C2<C3)
cout<<"C2 is smaller"<<endl;
else
cout<<"C3 is smaller"<<endl;
system("pause");
return 0;
}