8.14.cpp
来自「这是C++的一部分练习程序!对初学者有一定的帮助作用。」· C++ 代码 · 共 33 行
CPP
33 行
#include <iostream.h>
class X
{
friend class Y;
public:
X(int i)
{ x=i; }
void Print()
{ cout<<"x="<<x<<','<<"s="<<s<<endl; }
private:
int x;
static int s;
};
int X::s=5;
class Y
{
public:
Y(int i)
{ y=i; }
void Print(X &r)
{ cout<<"x="<<r.x<<','<<"y="<<y<<endl; }
private:
int y;
};
void main()
{
X m(2);
m.Print();
Y n(8);
n.Print(m);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?