-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFFusingclass.cpp
More file actions
51 lines (47 loc) · 993 Bytes
/
Copy pathFFusingclass.cpp
File metadata and controls
51 lines (47 loc) · 993 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
#include<iostream>
using namespace std;
class car2;
class car1{
private:
float p1,d1;
public:
void setdata()
{
cout<<"Enter petrol for 1: ";
cin>>p1;
cout<<"Enter distance for 1: ";
cin>>d1;
}
friend void sum(car1,car2);
};
class car2{
private:
float p2,d2;
public:
void setdata()
{
cout<<"Enter petrol for 2: ";
cin>>p2;
cout<<"Enter distance for 2: ";
cin>>d2;
}
friend void sum(car1,car2);
};
void sum(car1 A,car2 B)
{
cout<<"Petrol in car 1 is: "<<A.p1<<" L"<<endl;
cout<<"Distance in car 1 is: "<<A.d1<<" km"<<endl;
cout<<"Petrol in car 2 is: "<<B.p2<<" L"<<endl;
cout<<"Distance in car 2 is: "<<B.d2<<" km"<<endl;
cout<<"Sum of petrol in car 1 and car 2 is: "<<(A.p1+B.p2)<<" L"<<endl;
cout<<"Sum of distance in car 1 and car 2 is: "<<(A.d1+B.d2)<<" km"<<endl;
}
int main()
{
car1 auddi;
car2 bmw;
auddi.setdata();
bmw.setdata();
sum(auddi,bmw);
return 0;
}