-
大小: 2KB文件類型: .cpp金幣: 1下載: 0 次發(fā)布日期: 2021-06-07
- 語言: C/C++
- 標(biāo)簽:
資源簡介
c++例程:類的簡單應(yīng)用,關(guān)于建立一個(gè)學(xué)生信息系統(tǒng)
代碼片段和文件信息
#include?
#include?
using?namespace?std;
class?student
{
private:
//學(xué)號(hào)、姓名、性別、專業(yè)、
//班級(jí)、年級(jí)、住址、電話
char?stuNo[10];
char?stuName[20];
char?stuSex[4];
char?stuZy[10];
char?stuClass[5];
char?stuGrade[6];
char?stuAdress[20];
char?stuPhone[12];
static?int?stu_Number?;//在這里只是相當(dāng)于聲明
public:
student();
student(student?&stu);
student(char?No[]?char?name[]);
~student();
void?input();//信息的輸入
void?output();//信息的輸出
static?void?output_wholeNum();
};
int?student::stu_Number?=?0;?//在類的外部需要定義而且加上類域訪問符初始化也通常同時(shí)進(jìn)行
student::student(student?&stu)
{
stu_Number++;
strcpy(stuNo?stu.stuNo);
strcpy(stuName?stu.stuName);
}
student::student()
{
stu_Number++;
cout<<“請(qǐng)輸入學(xué)號(hào):“;?? cin>>stuNo;
cout<<“請(qǐng)輸入姓名:“; cin>>stuName;
}
student::student(
評(píng)論
共有 條評(píng)論