Practical 15
#include<iostream>
using namespace std;
class DEF;
class ABC
{
int a;
public:
void getdata()
{
cout<<"Enter a number:";
cin>>a;
}
friend void max(ABC,DEF);
};
class DEF
{
int x;
public:
void getdata()
{
cout<<"Enter a number:";
cin>>x;
}
friend void max(ABC,DEF);
};
void max(ABC p,DEF q)
{
if(p.a > q.x)
cout<<p.a<<" is maximum"<<endl;
else
cout<<q.x<<" is maximum"<<endl;
}
int main()
{
ABC m;
m.getdata();
DEF n;
n.getdata();
max(m,n);
}
output : enter a number
5
enter a number 7
7 is maximum
No comments:
Post a Comment