We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d45ea2d commit 4f36ad1Copy full SHA for 4f36ad1
friendclass.cpp
@@ -0,0 +1,55 @@
1
+#include<iostream.h>
2
+#include<conio.h>
3
+class ABC;
4
+class XYZ
5
+{
6
+ int x;
7
+ public:XYZ()
8
+ {
9
+ x=0;
10
+ }
11
+ void getdata(int b)
12
13
+ x=b;
14
15
+ friend void large(XYZ,ABC);
16
+};
17
+class ABC
18
19
+ int a;
20
+ public:ABC()
21
22
+ a=0;
23
24
+ void getdata(int c)
25
26
+ a=c;
27
28
29
30
+void large(XYZ m,ABC n)
31
32
+ if(m.x>=n.a)
33
34
+ cout<<m.x<<" is large ";
35
36
+ else
37
38
+ cout<<n.a<<" is large ";
39
40
+}
41
+void main()
42
43
+ int i,j;
44
+ clrscr();
45
+ ABC abc;
46
+ cout<<"\nEnter the 1st number : ";
47
+ cin>>i;
48
+ abc.getdata(i);
49
+ XYZ xyz;
50
+ cout<<"\nEnter 2nd number : ";
51
+ cin>>j;
52
+ xyz.getdata(j);
53
+ large(xyz,abc);
54
+ getch();
55
0 commit comments