Description
Object Oriented Programming 2
Lab Assignment-5 (Binary Operator Overloading)
1) Create a class Rectangle.
Private members of class Rectangle:
Length, breadth.
Create Member function:
Public: double getArea ( ) void setLenght ( double ) void setBreadth ( double)
Declare overloading function use (+) operator to add two Rectangle objects.
In the main ( ) function set rectangle length, breadth with member functions and use area function to print area of each rectangle.
Then declare a third object use overloading function to get area of third object.
2) Create a class Distance.
Private members of class Distance:
Kilometer, meter.
Create default constructer and parameter constructer.
Create Member function:
Void showDistance()
Declare overloading function use ( = =) operator to compare two distances. In the main ( )function set Distance kilometer, meter and use show distance to print of each distance. Then use overloading function to get difference of two distances.




Reviews
There are no reviews yet.