来自「C语言相关程序」· 代码 · 共 40 行

TXT
40
字号
#include<iostream.h>
#include<string.h>
class studentid
{
public:
	studentid(int d=0)
	{
		value=d;
		cout<<"11qiandaodexuesheng ID shi: "<<value<<endl;
	}
	~studentid()
	{
		cout<<"12destructing id shi:  "<<value<<endl;
	}
protected:
	int value;
};
class student
{
public:
	student(char *pname="no name",int ssID=0):id(ssID)
	{
		cout<<"21Constructing student "<<pname<<endl;
		strncpy(name,pname,sizeof(name));
		name[sizeof(name)-1]='\n';
	}
~student()
{
	cout<<"调用第2个函数"<<endl;
}
protected:
	char name[20];
	studentid id;

};
void main()
{
	student s("zhaoyulong",1986);
	student t("wangxu");
}

⌨️ 快捷键说明

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