freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內容

第4章類和對象二-在線瀏覽

2024-08-31 23:48本頁面
  

【正文】 成員 。 從而實現(xiàn)了同一個類的不同對象之間的數(shù)據(jù)共享 。 例 。 ~Student()。 // 輸出姓名 、 學號和成績 void show_count_sum_ave()。 // 學生姓名 char *stu_no。 // 學生成績 static int count。 // 靜態(tài)數(shù)據(jù)成員 ,統(tǒng)計總成績 static float ave。 Student::Student(char *name1,char *stu_no1,float score1 ) { name=new char[strlen(name1)+1]。 stu_no=new char[strlen(stu_no1)+1]。 score=score1。 // 累加學生人數(shù) sum=sum+score。 // 計算平均成績 } Student::~Student() { delete []name。 count。 } void Student::show() { cout\n name: name。 cout\n score: score。 // 輸出靜態(tài)數(shù)據(jù)成員 count cout\n sum: sum。 // 輸出靜態(tài)數(shù)據(jù)成員 ave } int Student::count=0。 // 靜態(tài)數(shù)員 sum初始化 float Student::ave=。 ()。 Student stu2(Zhanghao,990202,85)。 ()。 與靜態(tài)數(shù)據(jù)成員類似 ,調用公有靜態(tài)成員函數(shù)的一般格式有如下幾種 : 類名 ::靜態(tài)成員函數(shù)名 (實參表 ) 對象 . 靜態(tài)成員函數(shù)名 (實參表 ) 對象指針 靜態(tài)成員函數(shù)名 (實參表 ) 例 。 // 學生姓名 char *stu_no。 // 學生成績 static int count。 // 靜態(tài)數(shù)據(jù)成員 ,統(tǒng)計總成績 public: Student(char *name1,char *stu_no1,float score1)。 void show()。 // 靜態(tài)成員函數(shù) , 輸出學生人數(shù)和總成績 }。 strcpy(name,name1)。 strcpy(stu_no,stu_no1)。 ++count。 // 累加總成績 } Student::~Student() { delete []name。 count。 } void Student::show() { cout\n name: name。 cout\n score: score。 // 輸出靜態(tài)數(shù)據(jù)成員 cout\n sum: sum。 // 靜態(tài)數(shù)據(jù)成員初始化 float Student::sum=。 ()。 // 使用類名訪問 靜態(tài)成員函數(shù) Student stu2(Zhanghao,990202,85)。 ()。 include class myclass { public: myclass() // 構造函數(shù) ,每定義一個對象 , 靜態(tài)數(shù)據(jù)成員 i加 1 { ++i。 // 聲明靜態(tài)數(shù)據(jù)成員 i }。 // 靜態(tài)數(shù)據(jù)成員 i初始化 , 不必在前面加 static main() { int *count=amp。 // 聲明一個 int型指針 , 指向類的靜態(tài)成員 myclass ob1,ob2,ob3,ob4。 // 通過指針直接
點擊復制文檔內容
環(huán)評公示相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1