l6_6.cpp
来自「《C++程序设计教程》-杨国兴-电子教案及例题 C++程序设计PPT课件 h」· C++ 代码 · 共 42 行
CPP
42 行
#include <iostream.h>
class A
{
private:
int x;
public:
void Display()
{
cout << x << endl;
}
int Getx()
{
return x;
}
friend class B;
};
class B
{
private:
A a;
public:
void Set(int i);
void Display();
};
void B::Set(int i)
{
a.x=i;
}
void B::Display()
{
cout << a.x << endl;
}
void main()
{
B b;
b.Set(10);
b.Display();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?