-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq28.cpp
41 lines (35 loc) · 796 Bytes
/
q28.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
#include <iostream>
using namespace std;
class First;
class Second;
class First {
int num;
public:
First () {
cout << "Enter value for num (class: First): ";
cin >> num;
}
void show_larger(Second& obj2);
};
class Second {
int num;
public:
Second () {
cout << "Enter value for num (class: Second): ";
cin >> num;
}
friend void First :: show_larger(Second& obj2);
};
void First :: show_larger(Second& obj2) {
if (num > obj2.num) {
cout << "Number from First class is larger!" << endl;
} else if (num < obj2.num) {
cout << "Number from Second class is larger!" << endl;
}
}
int main() {
First f;
Second s;
f.show_larger(s);
return 0;
}