#include
using namespace std;
void add(int x,int y)
{
cout<<"add中x="<
cout<<"add中y="< cout<<"x+y="<}
int main()
{
int x=800;
int y=900;
add(x,y);
/* cout<<"main中x="<
cout<<"main中y="< cout<<"x+y="<
}
******************************************************************************************
#include
using namespace std;
class A;
void set(A a);
class A
{
friend void set(A a);
private:
int x;
int y;
};
void set(A a)
{
a.x=100;
a.y=200;
cout<<"a.x="<
cout<<"a.y="<}
int main()
{
A a;
set(a);
return 0;
}
***************************************************************************************
#include
using namespace std;
class A;
class B
{
public:
void set(A a);
void print(A a);
};
class A
{
friend void B::set(A a);
private:
int x;
int y;
};
void B::set(A a)
{
a.x=100;
a.y=200;
cout<<"a.x"<
A a;
B b;
b.set(a);
return 0;
}
*******************************************************************************
#include
using namespace std;
class B;
class A
{
friend class B;
private:
int x;
int y;
};
class B
{
public:
void set(A &a)
{
a.x=100;
a.y=200;
}
void print(A &a)
{
cout<<"a.x="<
};
int main()
{
A a;
B b;
b.set(a);
b.print(a);
return 0;
}
阅读(1567) | 评论(0) | 转发(1) |