第十五周 用檔案儲存學生名單

2021-06-22 08:57:25 字數 1138 閱讀 9092

#include #include#include#includeusing namespace std;

//定義學生類

class student

; ~student();

double get_total();

static int getstu_num();

static double gettotal_sum();

friend istream& operator>>(istream &in, student &s); //可以定義input函式替代

friend ostream& operator<<(ostream &out, student &s); //可以定義display函式替代

//宣告必要的成員函式

private:

string name;

double cpp;

double math;

double english;

double total;

static int stu_num; //學生人數,處理為類的靜態成員合適

static double total_sum; //學生總分和

};int student::stu_num = 0;

double student::total_sum = 0;

int student::getstu_num()

student::~student()

double student::get_total ()

double student::gettotal_sum ()

istream& operator>>(istream &input, student &s)

ostream& operator << (ostream &output,student&t)

int main()

while(readfile>>stu[i])

readfile.close();

ofstream writefile("scorepass.dat",ios::out);

if(!writefile)

for (int i=0;i}

return 0;

}

第十五周專案2 用檔案儲存的學生名單

程式的版權和版本宣告部分 檔名稱 cpp 作 者 王英華 完成日期 2014年6月8日 版本號 v1.0 輸入描述 略 問題描述 略 include include include include includeusing namespace std 定義學生類 class student stud...

用檔案儲存學生名單

煙台大學計算機學院學生 all right reserved.檔名稱 用檔案儲存學生名單 完成日期 2014年6月2日 版本號 v1.0 對任務及求解方法的描述部分 用檔案儲存學生名單 我的程式 include include include using namespace std 定義學生類 cl...

第十四周專案2 用檔案儲存的學生名單

問題及 檔名稱 project.cpp 作 者 陳文青 完成日期 2015年6月16日 版 本 號 v1.0 問題描述 1 定義學生類,其中包含姓名 c 課 高數和英語成績及總分資料成員。2 用物件陣列進行儲存學生的成績,讀入成績並計算總分 將總分高於平均總分且沒掛科的同學的資訊儲存到檔案pass ...