當前位置:編程學習大全網 - 編程語言 - 個人信息編程定義

個人信息編程定義

# include & ltstring.h & gt

# include & ltiostream & gt

使用命名空間std

階級人士

{

公共:

人():年齡(0)

{

memset(名稱,0,19);

memset(性別,0,4);

}

char name[20];

char sex[5];//數據“男”或“女”

int age

};

班級分數

{

公共:

分數():m _語文(0),m _數學(0),m _英語(0)

{

}

float m _中文;

float m _ math//數學

float m _ English

};

Class student: private person //私有繼承基類的pulic成員,在派生類中是私有的。

{

公共:

學生()

{

memset(數字,0,4);

}

私人:

字符數[5];// 4位數的學號

分數分數;//結果

公共:

Void SetNumber(char *pNum) //設置學號。

{

strcpy(數字,pNum);

}

Void GetNumber(char *pNum) //獲取學號。

{

strcpy(pNum,number);

}

void SetSocres(float fch,float fmath,float fEnglish)

{

scores.m _ Chinese = fch

scores.m _ math = fmath

scores.m _ English = fEnglish

}

void GetSocres(分數& ampSc) //獲取所有結果

{

sc.m _中文= scores.m _中文;

sc . m _ math = scores . m _ math;

sc.m _英語= scores.m _英語;

}

Void GetName(char *pName) //獲取名稱。

{

strcpy(pName,name);

}

Void SetName(char *pName) //設置名稱。

{

strcpy(名稱,pName);

}

void GetSex(char *pSex)

{

strcpy(pSex,sex);

}

void SetSex(char *pSex)

{

strcpy(sex,pSex);

}

int GetAge()

{

回歸年齡;

}

無效分期付款(內部)

{

年齡= nAge

}

};

int main()

{

學生stu[3];

斯圖[0]。SetName(" AA ");

斯圖[0]。SetSex(“男性”);

斯圖[0]。SetAge(18);

斯圖[0]。set number(" 001 ");

斯圖[0]。SetSocres(89.0,87.0,86.0);

斯圖[1]。SetName(" BB ");

斯圖[1]。SetSex(“男性”);

斯圖[1]。SetAge(18);

斯圖[1]。set number(" 002 ");

斯圖[1]。SetSocres(67.0,89.0,78.0);

斯圖[2]。SetName(" CC ");

斯圖[2]。SetSex(“女性”);

斯圖[2]。SetAge(18);

斯圖[2]。set number(" 003 ");

斯圖[2]。SetSocres(44.0,66.0,88.0);

分數temp

Printf("輸出信息:\ n ");

Printf("學號\ tname \ t gender \ tAge \ t Chinese \ tMath \ t English \ t \ n ");

for(int I = 0;我& lt3;i++)

{

充電溫度[5];

斯圖[我]。get number(temp);

printf("%s\t ",temp);

char temp 1[20];

斯圖[我]。GetName(temp 1);

printf("%s\t ",temp 1);

char temp 2[5];

斯圖[我]。GetSex(temp 2);

printf("%s\t ",temp 2);

printf("%d\t ",stu[i]。GetAge());

分數sc;

斯圖[我]。GetSocres(sc);

printf("%3.1f\t ",sc . m _ Chinese);

printf("%3.1f\t ",sc . m _ math);

printf("%3.1f\t\n ",sc . m _ English);

}

系統(“暫停”);

返回0;

}

  • 上一篇:西門子S7200和S7300 PLC的不同之處
  • 下一篇:985本碩臨床醫學,現在轉行去計算機可能嗎?
  • copyright 2024編程學習大全網