Write a C++ program to find greatest number among two numbers from two different classes using friend function.
#include<iostream.h>
#include<conio.h>
class second;
class first
{
int x;
public:
void getx()
{
cout<<"\nEnter the value of x:";
cin>>x;
}
friend void max(first,second);
};
class second
{
int y;
public:
void gety()
{
cout<<"\nEnter the value of y:";
cin>>y;
}
friend void max(first,second);
};
void max(first a,second b)
{
if(a.x>b.y)
{
cout<<"\Greater value is:"<<a.x;
}
else
{
cout<<"\nGreater value is:"<<b.y;
}
}
void main()
{
first a;
second b;
clrscr();
a.getx();
b.gety();
max(a,b);
getch();
}