class_student.cpp

来自「经常使用的一些源程序.包括一些模板.在VC++6.0下通过.」· C++ 代码 · 共 81 行

CPP
81
字号
#include <iostream>
#include <string>
using namespace std;

/*main information*/
void info()
{
	cout << "class student";
	cout << endl << endl;
}

class student
{
public:
	student(int num = 111, string nam = "xiao", string lov = "basketball");
	show();
	set(int, string, string);
	~student();
private:
	int number;
	string name;
	string love;
};

student::student(int num, string nam, string lov)
{
	number = num;
	name = nam;
	love = lov;
}

student::show()
{
	cout << "\n_________________";
	cout << "\nnumber: " << number;
	cout << "\n name : " << name;
	cout << "\n love : " << love;
}

student::~student()
{
	cout << "\nover";
}

student::set(int num = 111, string nam = "xiao", string lov = "sleeping")
{
	number = num;
	name = nam;
	love = lov;
}

/*source code*/
void test()
{
	//input code here......
	student stu[5];
	for (int i = 0; i < 5; i++)
	{
		stu[i].set(i);
		stu[i].show();
	}
}

/*information of source code owner*/
void end()
{
	cout << "\n\n\n______________\n";
	cout << "xiao zhiqiang\n";
	cout << "inxk@163.com\n";
	cout << "Sep,2006";
	getchar();
}

/*the main code*/
void main()
{
	info();
	test();
	end();
}

⌨️ 快捷键说明

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