I want to find the maximum of 2 numbers but instead of the simple method, i need to use 2 classes and friend functions. How to implement it? I am using the following code but the code isn't working.
#include<iostream>
using namespace std;
class one
{
int a;
public:
friend int cal(one a);
};
class two
{
int b;
public:
friend int cal(one a,two b);
};
cal(int f,int g)
{
int ans=(x.a>y.b)?x.a:y.b;
}
int main()
{
one x;
two y;
cal(10,20);
}
Output
Enter 2 nos.:133 21
Sample Output
Biggest no.:133