forked from GCET-CSE2022/OOP-Cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPassingAndReturningObjects.cpp
More file actions
66 lines (47 loc) · 960 Bytes
/
Copy pathPassingAndReturningObjects.cpp
File metadata and controls
66 lines (47 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include<iostream>
using namespace std;
class Distance
{
private:
int feet;
float inches;
public:
//CONSTRUCTOR BODY
Distance()
{
inches = 0;
feet = 0.0;
}
// GETDATA FUNCTION
void GetData()
{
cout <<endl<<"Enter Feet: ";
cin >>feet;
cout <<endl<<"Enter inches: ";
cin >>inches;
}
// DISPLAY DATA FUNCTION
void DisplayData()
{
cout<<endl<<" Feet = "<<feet;
cout<<endl<<"Inches = "<<inches;
}
// ADDITION OF TWO DISTANCES
Distance AddDistances(Distance DT1, Distance DT2)
{
Distance DTS;
DTS.feet =feet+DT1.feet+DT2.feet;
DTS.inches = inches +DT1.inches+DT2.inches;
return DTS;
}
};
int main()
{
Distance obj1,obj2,obj3,objSum;
obj1.GetData();
obj2.GetData();
obj3.GetData();
objSum=obj1.AddDistances(obj2,obj3);
objSum.DisplayData();
return (0);
}