Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream.h>
- class ABC;
- class XYZ
- {
- int a;
- public :
- friend void max(XYZ,ABC);
- };
- class ABC
- {
- int b;
- public:
- friend void max(XYZ,ABC);
- };
- void max(XYZ p,ABC q)
- {
- cout<<"enter two values to find the max:\n";
- cin>>p.a>>q.b;
- if(p.a>=q.b)
- cout<<"the greatest is "<<p.a<<endl;
- else
- cout<<"the greatest is "<<q.b<<endl;
- }
- int main()
- {
- XYZ q;
- ABC w;
- max(q,w);
- return 0;
- }
- #include<iostream.h>
- class ABC;
- class XYZ
- {
- int a;
- public :
- friend void max(XYZ,ABC);
- };
- class ABC
- {
- int b;
- public:
- friend void max(XYZ,ABC);
- };
- void max(XYZ p,ABC q)
- {
- int avg;
- cout<<"enter two values to find the average:\n";
- cin>>p.a>>q.b;
- avg=(p.a+q.b)/2;
- cout<<"the average of "<<p.a<<" and "<<q.b<<" is "<<avg<<endl;
- }
- int main()
- {
- XYZ q;
- ABC w;
- max(q,w);
- return 0;
- }
- #include<iostream.h>
- class ABC;
- class XYZ
- {
- int a;
- public :
- friend void max(XYZ,ABC);
- };
- class ABC
- {
- int b;
- public:
- friend void max(XYZ,ABC);
- };
- void max(XYZ p,ABC q)
- {
- int t=0;
- cout<<"enter two values to swap:\n";
- cin>>p.a>>q.b;
- cout<<"values before swapping are a= "<<p.a<<" b= "<<q.b<<endl;
- t=p.a;
- p.a=q.b;
- q.b=t;
- cout<<"values after swapping are a= "<<p.a<<" b= "<<q.b<<endl;
- }
- int main()
- {
- XYZ q;
- ABC w;
- max(q,w);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment