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

📄 l6_7.cpp

📁 《C++程序设计教程》-杨国兴-电子教案及例题 C++程序设计PPT课件 html课件 例题
💻 CPP
字号:
#include <iostream.h>
#include <string.h>
class CStudent
{
private:
	int number;
	char name[10];
	static int total;
public:
	CStudent(int xh, char *xm);
	~CStudent();
	int GetTotal();
	int GetNumber();

};

CStudent::CStudent(int xh, char *xm)
{
	number = xh;
	strcpy(name, xm);
	total++;
}

CStudent::~CStudent()
{
	total--;
}

int CStudent::GetTotal()
{
	return total;
}

int CStudent::GetNumber()
{
	return number;
}

int CStudent::total = 0;
void func();

void main()
{
	CStudent s1(10001, "AAAAAA" );
	cout << s1.GetNumber() << endl;
	cout << s1.GetTotal() << endl;
	CStudent s2(10002, "BBBBBB" );
	cout << s2.GetNumber() << endl;
	cout << s1.GetTotal() << endl;
	cout << s2.GetTotal() << endl;
	func();
	cout << s1.GetNumber() << endl;
	cout << s1.GetTotal() << endl;
	cout << CStudent::GetTotal() << endl;
//	cout << CStudent::total << endl;
}

void func()
{
	CStudent s3(10003, "CCCCCC" );
	cout << s3.GetNumber() << endl;
	cout << s3.GetTotal() << endl;
}

⌨️ 快捷键说明

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