#include<iostream.h>
#include<conio.h>
class boy
{ private:
int income1,income2;
public:
void setdata(int n1,int n2)
{ income1=n1;
income2=n2;
}
friend class girl;
};
class girl
{ int income;
public:
int g_fun(boy b1)
{ return b1.income1+b1.income2; }
void set_data(int n)
{ income=n; }
void show()
{ boy b1;
b1.setdata(300,500);
cout<<"\n\n boy income = "<<b1.income1;
cout<<"\n\n girl income = "<<income;
}
};
void main()
{ boy b1;
girl g1;
clrscr();
b1.setdata(100,200);
g1.set_data(300);
g1.show();
cout<<"\n\n The total income of boy "<<g1.g_fun(b1);
getch();
}
Comments
Post a Comment