Que-Make a program for friend function?
#include<iostream>
using namespace std;
class first
{
int a;
public:
void getdata ()
{
a=10;
}
friend class krishna ;
};
class krishna
{
public:
void display (first &t)
{
cout<<"no. is "<<t.a;
}
};
int main()
{
first c;
krishna b;
c.getdata();
b.display(c);
return 0;
}
result:-
Tags
Friend function