Concept of Friend Function in C++
Friend Function of C++
#include<iostream.h>
#include<conio.h>
class fri
{
int a,b;
public:
void input(int x,int y)
{
a=x;
b=y;
}
friend int add(fri t)
{
int sum;
sum=(t.a+t.b);
cout<<"Sum is:"<<sum;
}
};
void main()
{
fri r;
r.input(2,8);
add(r);
getch();
}
output
No comments:
Post a Comment