-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path30.cpp
66 lines (52 loc) · 873 Bytes
/
30.cpp
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 c2;
class c1
{
int val;
public:
void indata(int a)
{
val = a;
};
void display(void)
{
cout << val << endl;
};
friend void exchange(c1 &, c2 &);
};
class c2
{
int value;
public:
void indata(int a)
{
value = a;
};
void display(void)
{
cout << value << endl;
};
friend void exchange(c1 &, c2 &);
};
void exchange(c1 &x, c2 &y)
{
int temp = x.val;
x.val = y.value;
y.value = temp;
};
int main()
{
c1 data1;
c2 data2;
data1.indata(5);
data2.indata(10);
cout << "The values before exchanging are " << endl;
data1.display();
data2.display();
exchange(data1, data2);
cout << "The values after exchanging are " << endl;
data1.display();
data2.display();
return 0;
}