4-1.txt

来自「思路很清晰的c++课件。例子很简明」· 文本 代码 · 共 28 行

TXT
28
字号
#include <iostream.h>

class base{		//基类
	int x;
public:
	void setx(int n){x=n;}
	void showx(){cout<<x<<endl;}
};

class derived:private base{		//私有派生类
	int y;
public:
	void setxy(int n,int m)
	{  setx(n);
	   y=m;
	}
	void showxy()
	{  cout<<x<<y<<endl;		//?
	}
};

void main()
{
	derived obj;
	obj.setxy(10,20);
	obj.showxy();
}

⌨️ 快捷键说明

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