#include<iostream.h>
#include<conio.h>
class two;
class one
{
private:
                int data1;
public:
                void setdata(int init)
                {
                                data1=init;
                }
                friend int add_both(one a,two b);
};
class two
{
private:
                int data2;
public:
                void setdata(int init)
                {
                                data2=init;
                }
                friend int add_both(one a,two b);
};
int add_both(one a,two b)
{
                return(a.data1+b.data2);
}
void main()
{
                one a;
                two b;
                clrscr();
                a.setdata(20);
                b.setdata(30);
                cout<<"Sum = "<<add_both(a,b);
                getch();
}
Advertisements