⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5-3-1.cpp

📁 学习c++的ppt
💻 CPP
字号:
#include <iostream.h>
class  X  {
    private:
        int x;
        static int y;
    public:
        void Set(int i){ 
		    x=i;
		}
        void Display(){
		    cout<<"x="<<x<<",y="<<y<<endl;
		}
        friend class Y;
};

class Y  {
    private:
        X a;
    public:
        Y(int i, int j);
        void  Display();
};
int X::y = 10;
Y::Y(int i, int j)
{  
	a.x = i; 
	X::y=j; 
}
void Y::Display()
{ 
	cout<<"x="<<a.x<<", y="<<X::y<<endl;
}
void main()
{   X b;   
    b.Set(15);  
	b.Display();
    Y c(16, 19);  
	c.Display();   
	b.Display();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -