Skip to content

Commit ee1be7b

Browse files
committed
OOP2 Lab 5 updated
1 parent c4c94bb commit ee1be7b

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
-16.5 KB
Binary file not shown.

OOP2_Lab5/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Practical Lab Assignment - Binary Operator Overloading
2+
3+
### Program 1
4+
```
5+
Create a class Rectangle.
6+
Private members of class Rectangle: Length, breadth.
7+
Create Member function:
8+
Public:
9+
double getArea()
10+
void setLength(double)
11+
void setBreadth(double)
12+
```
13+
Declare overloading function use **(+)** operator to add two Rectangle objects.
14+
In the `main()` function set rectangle length, breadth with member functions and use area function to print area of each rectangle.
15+
Then declare a third object use overloading function to get area of third object.
16+
17+
### Program 2
18+
```
19+
Create a class Distance.
20+
Private members of class Distance: Kilometer, meter.
21+
Create default constructor and parameter constructor.
22+
Create Member function:
23+
void showDistance()
24+
```
25+
Declare overloading function use **(==)** operator to compare two distances.
26+
In the `main()` function set Distance kilometer, meter and use show distance to print of each distance.
27+
Then use overloading function to get difference of two distances.

0 commit comments

Comments
 (0)