friend class by using c++
#include<iostream.h>
#include<conio.h>
class abc
{
inta,b;
public:
void read()
{
cout<<"\nEnter the first number:";
cin>>a;
cout<<"\nEnter the scound number:";
cin>>b;
}
friend class sum;
};
class Sum
{
public;
int c;
void add(abc a1)
{
c=a1.a+a1.b;
cout<<"\nSum="<<c;
}
};
void main()
{
abc a1;
sum s1;
clrscr();
a1.read();
s1.add(a1);
getch();
}
Comments
Post a Comment