/*
Largest Number from two using classes Friend Function
*/
#include<iostream>
using namespace std;
class Demo;
class Sample
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number:";
cin>>a;
}
friend void max(Sample S,Demo D);
};
class Demo
{
int b;
public:
void accept()
{
cout<<"\n\n Enter any number:";
cin>>b;
}
friend void max(Sample S,Demo D);
};
void max(Sample S,Demo D)
{
if(S.a>D.b)
cout<<"\n\n Largest:"<<S.a;
else if(S.a<D.b)
cout<<"\n\n Largest:"<<D.b;
else
cout<<"\n\n Both are Equal.";
}
int main()
{
Sample S;
Demo D;
S.accept();
D.accept();
max(S,D);
return 0;
}
Largest Number from two using classes Friend Function
*/
#include<iostream>
using namespace std;
class Demo;
class Sample
{
int a;
public:
void accept()
{
cout<<"\n\n Enter any number:";
cin>>a;
}
friend void max(Sample S,Demo D);
};
class Demo
{
int b;
public:
void accept()
{
cout<<"\n\n Enter any number:";
cin>>b;
}
friend void max(Sample S,Demo D);
};
void max(Sample S,Demo D)
{
if(S.a>D.b)
cout<<"\n\n Largest:"<<S.a;
else if(S.a<D.b)
cout<<"\n\n Largest:"<<D.b;
else
cout<<"\n\n Both are Equal.";
}
int main()
{
Sample S;
Demo D;
S.accept();
D.accept();
max(S,D);
return 0;
}