//code for pass object in friend function
#include<iostream.h>
#include<conio.h>
class temp
{
int a,b;
public:
void get();
friend void check(temp);
};
void temp::get()
{
cin>>a>>b;
}
void check(temp t1)
{
cout<<"\n"<<t1.a+t1.b;
}
int main()
{
temp t1,t2;
clrscr();
t1.get();
check(t1);
getch();
return(0);
}
#include<iostream.h>
#include<conio.h>
class temp
{
int a,b;
public:
void get();
friend void check(temp);
};
void temp::get()
{
cin>>a>>b;
}
void check(temp t1)
{
cout<<"\n"<<t1.a+t1.b;
}
int main()
{
temp t1,t2;
clrscr();
t1.get();
check(t1);
getch();
return(0);
}
No comments:
Post a Comment