//Friend Function
#include<iostream.h>
#include<conio.h>
class sample
{
clrscr();
private:
int x;
public:
void getdata();
friend void display (class sample);
}
;
void sample::getdata()
{
cout<<"enter any integer value"<<endl;
cin>>x;
}
void display(class sample abc)
{
cout<<"entered no is"<<abc.x<<endl;
}
void main()
{
clrscr();
sample s;
s.getdata();
display(s);
getch();
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.