網(wǎng)站首頁 編程語言 正文
本文實(shí)例為大家分享了C++實(shí)現(xiàn)簡單信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
信息管理系統(tǒng)
因?yàn)閷W(xué)校布置了寫一個(gè)信息管理系統(tǒng)的作業(yè),所以寫下了這個(gè)信息管理系統(tǒng),這是用cpp寫的一個(gè)簡單程序。
基本思路是通過控制臺程序,然后通過數(shù)字命令來進(jìn)行操作。
該程序編譯了多文件;
因?yàn)槭菍W(xué)校的作業(yè)所以我把萬能頭換成了
#include"stdc++.h"
功能和萬能頭一致。
該系統(tǒng)使用了鏈表來鏈接各個(gè)數(shù)據(jù)。
程序的基本功能是打算寫兩個(gè)系統(tǒng),輸入1和賬號密碼進(jìn)入學(xué)生管理系統(tǒng)
輸入2和賬號密碼進(jìn)入教師管理系統(tǒng)
但是我只寫了教師管理系統(tǒng),因?yàn)檫@是學(xué)校的作業(yè),而且之前我有寫過學(xué)生管理系統(tǒng)了,所以沒打算再寫一次,以后有時(shí)間再說。
進(jìn)入教師管理系統(tǒng)以后 :
輸入1:用戶自己增加教師信息
輸入2:用戶可以通過教師工號更改教師的姓名或身份證號或年齡或教師工號或者工資或者執(zhí)教課程或課程學(xué)分。
輸入3:通過教師工號來刪除特定教師
輸入4:顯示所有的教師信息
輸入5:從指定文件(D:\1808190126許達(dá)峰\Data.txt)讀入信息。
輸入6:顯示符合某個(gè)特定信息的教師,可以用教師姓名、身份證、工號、工資、年齡、執(zhí)教課程進(jìn)行檢索
輸入7:可以通過教師工號、工資、年齡進(jìn)行排序(從小到大)
輸入0:退出系統(tǒng)。
主程序代碼如下:
#include"stdc++.h" #include"interface.h" #include"actions.h" #include"teacherMessage.h" #includeusing namespace std; int main(){ ?? ?system("color 0F"); ?? ?//信息管理系統(tǒng)選項(xiàng) ?? ?tasks(); ?? ?return 0; }
這里包括了萬能頭、界面樣式、用戶操作、教師類定義四個(gè)頭文件。
萬能頭文件如下:
#ifndef _GLIBCXX_NO_ASSERT #include#endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #if __cplusplus >= 201103L #include #include #include #include #include #include #include #include #include #endif // C++ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include
#include
界面樣式代碼如下:
.h文件代碼:
#ifndef INTERFACE #define INTERFACE #include"stdc++.h" using namespace std; //教師信息管理系統(tǒng)界面樣式 void MainFace(); //信息管理系統(tǒng)界面樣式 void outFace(); #endif INTERFACE
.cpp文件代碼:
#include"interface.h" //教師信息管理系統(tǒng)界面樣式 void MainFace(){ ? ? cout<<" ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?"<<"---------------------------------------------------------------"<
用戶操作代碼如下:
.h文件
#ifndef ACTIONS #define ACTIONS #include"stdc++.h" #include"teacherMessage.h" using namespace std; typedef struct teacherDate * List; typedef struct teacherDate Data; //鏈表的構(gòu)成元素 struct teacherDate { ? ? Teacher self; ? ? List next; }; //教師信息管理系統(tǒng)選項(xiàng) void acts(); //主界面選項(xiàng) void tasks(); #endif
.cpp文件
#include"actions.h" #include"interface.h" #include"teacherSystem.h" #include//賬號密碼 const string R_Id="teacher"; const string R_password="123456789"; //主界面選項(xiàng) void tasks(){ ? ? int task; ? ? outFace(); ? ? cout<<"請輸入0-2:";? ? ? while(cin>>task){ ? ? ? ? if(task==0){ ?? ??? ??? ?cout<<"拜拜"< >Id>>passwrod; ?? ??? ??? ?//檢驗(yàn)賬號密碼是否正確 ? ? ? ? ? ? if(Id==R_Id){ ?? ??? ??? ??? ?if(passwrod==R_password){ ? ? ? ? ? ? ? ? acts(); ?? ??? ??? ??? ?}else{ ?? ??? ??? ??? ??? ?cout<<"密碼錯(cuò)誤"< >a){ ? ? ? ? if(a==1){ ?? ??? ??? ?//增加教師信息 ?? ??? ??? ?head=add(head); ? ? ? ? }else if(a==2){ ?? ??? ??? ?//更改教師信息 ?? ??? ??? ?head=changeActs(head); ? ? ? ? }else if(a==3){ ?? ??? ??? ?//刪除教師信息 ?? ??? ??? ?head=excludeActs(head); ? ? ? ? }else if(a==4){ ?? ??? ??? ?//顯示所有教師信息 ?? ??? ??? ?head=dataFace(head); ? ? ? ? }else if(a==5){ ?? ??? ??? ?//從文件錄入教師信息 ?? ??? ??? ?head=readin(head); ? ? ? ? }else if(a==6){ ?? ??? ??? ?//顯示教師信息 ?? ??? ??? ?head=showTeacherActs(head); ? ? ? ? }else if(a==7){ ?? ??? ??? ?//對教師信息進(jìn)行排序 ? ? ? ? ? ? head=softData(head); ? ? ? ? }else if(a==0){ ?? ??? ??? ?cout<<"將返回主界面"<
用戶操作定義還包括下屬的數(shù)字命令文件
數(shù)字命令文件代碼如下:
.h文件
#ifndef TEACHERSYSTEM #define TEACHERSYSTEM #include"stdc++.h" #include"actions.h" using namespace std; //增加教師信息 List add(List head); //更改教師信息 List changeActs(List head); //刪除教師信息 List excludeActs(List head); //顯示所有教師信息 List dataFace(List head); //從文件錄入教師信息 List readin(List head); //顯示教師信息 List showTeacherActs(List head); //對教師信息進(jìn)行排序 List softData(List head); //清除所有數(shù)據(jù),防止內(nèi)存泄露 List clearAll(List head); //根據(jù)教師工號搜索指定教師 List findTeacher(List head,string teacherId); #endif TEACHERSYSTEM
.cpp文件
#include"teacherSystem.h" #include"interface.h" #include"teacherMessage.h" #include"changeActions.h" //增加教師信息 List add(List head){ ? ? string Name,Age,teacherId,salary; ?? ?string Identify; ?? ?string LesName,Point; ?? ?Lesson course; ? ? if(head==NULL){? ? ? ? ? //為首結(jié)點(diǎn)動態(tài)分配空間 ? ? ? ? head=new Data; ? ? ? ? ? ? ? ? ? ? ? ? ? ? cout<<"請依次輸入教師的姓名、身份證號(后四位)、年齡、教師工號、工資、執(zhí)教課程、課程學(xué)分:"; ? ? ? ? cin>>Name>>Identify>>Age>>teacherId>>salary>>LesName>>Point; ? ? ? ? //將數(shù)據(jù)傳入Teacher類中 ?? ??? ?course.getData(LesName,Point); ? ? ? ? head->self.getData(Name,Identify,Age,teacherId,salary,course); ? ? ? ? //令下一個(gè)結(jié)點(diǎn)為空 ? ? ? ? ? ? ? ? ? ? head->next=NULL; ? ? }else{ ? ? ? ? List current,record; ? ? ? ? current=head; ? ? ? ? //通過遍歷找到空結(jié)點(diǎn),把數(shù)據(jù)分配到空結(jié)點(diǎn)中 ? ? ? ? while(current->next){ ? ? ? ? ? ? current=current->next; ?? ??? ??? ?record=current->next; ? ? ? ? } ?? ??? ?if(current==head) ?? ??? ??? ?record=current->next; ? ? ? ? cout<<"請依次輸入教師的姓名、身份證號(后四位)、年齡、教師工號、工資、執(zhí)教課程、課程學(xué)分:"; ? ? ? ? cin>>Name>>Identify>>Age>>teacherId>>salary>>LesName>>Point; ?? ??? ?course.getData(LesName,Point); ? ? ? ? //為新結(jié)點(diǎn)動態(tài)分配空間 ? ? ? ? record= new Data; ? ? ? ? record->self.getData(Name,Identify,Age,teacherId,salary,course); ?? ??? ?//令下一個(gè)結(jié)點(diǎn)為空 ?? ??? ?record->next=NULL; ?? ??? ?current->next=record; ? ? } ?? ?return head; } //更改教師信息 List changeActs(List head){ ? ? int choose; ? ? string teacherId; ? ? cout<<"---------------------------------------------------"<>choose; ?? ?cout< >teacherId; ? ? if(choose==1){ ? ? ? ? changeName(head,teacherId); ? ? }else if(choose==2){ ? ? ? ? changeIdentify(head,teacherId); ? ? }else if(choose==3){ ? ? ? ? changeAge(head,teacherId); ? ? }else if(choose==4){ ? ? ? ? changeTeacherId(head,teacherId); ? ? }else if(choose==5){ ? ? ? ? changeSalary(head,teacherId); ? ? }else if(choose==6){ ?? ??? ?changeLesName(head,teacherId); ?? ?}else if(choose==7){ ?? ??? ?changePoint(head,teacherId); ?? ?}else{ ? ? ? ? cout<<"無效輸入"< self.showmessage(); ?? ??? ??? ?cout< next; ?? ??? ?} ?? ?} ? ? return head; } //刪除教師信息 List excludeActs(List head){ ? ? string teacherId; ? ? cout<<"請輸入你要?jiǎng)h除的教師的教師工號:"; ? ? cin>>teacherId; ? ? List current=head,before; ? ?? ? ? if(current){ ?? ??? ?while(current->next!=NULL&¤t->self.getTeacherId()!=teacherId){ ?? ??? ??? ?before=current; ?? ??? ??? ?current=current->next; ?? ??? ?} ? ? ? ? if(current->self.getTeacherId()==teacherId){ ? ? ? ? ? ? if(current==head){ ? ? ? ? ? ? ? ? List record=head; ? ? ? ? ? ? ? ? head=head->next; ? ? ? ? ? ? ? ? delete record; ? ? ? ? ? ? ? ? return head; ? ? ? ? ? ? }else{ ? ? ? ? ? ? ? ? before->next=current->next; ? ? ? ? ? ? ? ? delete current; ? ? ? ? ? ? } ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在!"< >choose; ? ? if(choose==1){ ? ? ? ? searchName(head); ? ? }else if(choose==2){ ? ? ? ? searchIdentify(head); ? ? }else if(choose==3){ ? ? ? ? searchTeacherId(head); ? ? }else if(choose==4){ ? ? ? ? searchSalary(head); ? ? }else if(choose==5){ ?? ??? ?searchAge(head); ?? ?}else if(choose==6){ ?? ??? ?searchCourseLesName(head); ?? ?}else{ ? ? ? ? cout<<"無效操作"< next){ ?? ??? ??? ?current=current->next; ?? ??? ??? ?recall=current->next; ?? ??? ?} ?? ??? ?if(current==head) ?? ??? ??? ?recall=current->next; ?? ?} ?? ?if(!fin.is_open()){ ?? ??? ?cout<<"打開文件失敗!"< >Name>>Identify>>Age>>teacherId>>salary>>LesName>>Point){ ?? ??? ??? ?recall=new Data;?? ??? ??? ? ?? ??? ??? ?if(head==NULL){ ?? ??? ??? ??? ?head=recall; ?? ??? ??? ?}else{ ?? ??? ??? ??? ?current->next=recall; ?? ??? ??? ?} ?? ??? ??? ?course.getData(LesName,Point); ?? ??? ??? ?recall->self.getData(Name,Identify,Age,teacherId,salary,course); ?? ??? ??? ?recall->next=NULL; ?? ??? ??? ?current=recall; ?? ??? ?} ?? ??? ?fin.clear(); ?? ?} ? ? return head; } //對教師信息進(jìn)行排序 List softData(List head){ ?? ?int choose; ? ? cout<<"-----------------------------------------"< >choose; ? ? if(choose==1){ ? ? ? ? head=bubbleSofAge(head); ? ? }else if(choose==2){ ? ? ? ? head=bubbleSoftTeacherId(head); ? ? }else if(choose==3){ ? ? ? ? head=bubbleSoftSalary(head); ? ? }else{ ? ? ? ? cout<<"a無效操作!"< next!=NULL&¤t->self.getTeacherId()!=teacherId){ ? ? ? ? current=current->next; ? ? } ? ? return current; } //清除所有數(shù)據(jù),防止內(nèi)存泄露 List clearAll(List head){ ? ? List current=head,record; ?? ?if(head!=NULL){ ? ? ? ? while(current){ ? ? ? ? ? ? record=current->next; ? ? ? ? ? ? delete current; ? ? ? ? ? ? current=record; ? ? ? ? } ?? ?} ? ? return head=NULL; }
教師系統(tǒng)操作還包括以下文件:
.h文件:
#ifndef CHANGEACTIONS #define CHANGEACTIONS #include"stdc++.h" #include"actions.h" using namespace std; //更改姓名 void changeName(List head,string teacherId); //更改身份證號 void changeIdentify(List head,string teacherId); //更改年齡 void changeAge(List head,string teacherId); //更改教師工號 void changeTeacherId(List head,string teacherId); //更改工資 void changeSalary(List head,string teacherId); //更改課程名稱 void changeLesName(List head,string teacherId); //更改課程學(xué)分 void changePoint(List head,string teacherId); //檢索姓名 void searchName(List head); //檢索身份證號 void searchIdentify(List head); //檢索教師工號 void searchTeacherId(List head); //檢索工資 void searchSalary(List head); //檢索年齡 void searchAge(List head); //根據(jù)執(zhí)教課程檢索 void searchCourseLesName(List head); //基于冒泡排序的根據(jù)教師年齡排序 List bubbleSofAge(List head); //基于冒泡排序的根據(jù)教師工號排序 List bubbleSoftTeacherId(List head); //基于冒泡排序的根據(jù)教師工資排序 List bubbleSoftSalary(List head); #endif CHANGEACITIONS
.cpp文件:
#include"changeActions.h" #include"teacherMessage.h" #include"teacherSystem.h" //更改姓名 void changeName(List head,string teacherId){ ? ? List current=findTeacher(head,teacherId); ? ? if(current){ ? ? ? ? if(current->self.getTeacherId()==teacherId){ ? ? ? ? ? ? string Name; ? ? ? ? ? ? cout<<"請輸入新名字"<>Name; ? ? ? ? ? ? current->self.changeName(Name); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string Identify; ? ? ? ? ? ? cout<<"請輸入新身份證號"< >Identify; ? ? ? ? ? ? current->self.changeIdentify(Identify); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string Age; ? ? ? ? ? ? cout<<"請輸入新年齡"< >Age; ? ? ? ? ? ? current->self.changeAge(Age); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string TeacgerId; ? ? ? ? ? ? cout<<"請輸入新教師工號"< >TeacgerId; ? ? ? ? ? ? current->self.changeTeacherId(TeacgerId); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string Salary; ? ? ? ? ? ? cout<<"請輸入新工資"< >Salary; ? ? ? ? ? ? current->self.changeSalary(Salary); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string LesName; ? ? ? ? ? ? cout<<"請輸入新課程名稱"< >LesName; ? ? ? ? ? ? current->self.changeCoureseLesName(LesName); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? string Point; ? ? ? ? ? ? cout<<"請輸入新課程學(xué)分"< >Point; ? ? ? ? ? ? current->self.changeCouresePoint(Point); ? ? ? ? }else{ ? ? ? ? ? ? cout<<"該教師不存在"< >Name; ?? ? ? ? cout<<"---------------------------------------------------------------------------"< self.getName()==Name){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< >Identify; ?? ? ? ? cout<<"---------------------------------------------------------------------------"< self.getIdentify()==Identify){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< >teacherId; ?? ? ? ? cout<<"---------------------------------------------------------------------------"< self.getTeacherId()==teacherId){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< >salary; ?? ? ? ? cout<<"---------------------------------------------------------------------------"< self.getSalary()==salary){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< >age; ?? ?//輸出樣式 ? ? cout<<"---------------------------------------------------------------------------"< self.getAge()==age){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< >LesName; ?? ?//輸出樣式 ? ? cout<<"---------------------------------------------------------------------------"< self.getCourseLesName()==LesName){ ? ? ? ? ? ? ? ? current->self.showmessage(); ?? ??? ??? ??? ?cout< next; ? ? ? ? } ? ? }else{ ? ? ? ? cout<<"該表格為空!"< next; ? ? } ?? ?current=head;? ?? ?//排序 ? ? for(int i=0;i next){ ?? ??? ??? ?record=current->next; ?? ??? ??? ?if(record->self.getAge() self.getAge()){ ?? ??? ??? ??? ?T=record->self; ?? ??? ??? ??? ?record->self=current->self; ?? ??? ??? ??? ?current->self=T; ?? ??? ??? ?} ?? ??? ??? ?current=current->next; ? ? ? ? } ?? ??? ?current=head; ? ? ? ? } ? ? return head; } //基于冒泡排序的根據(jù)教師工號排序 List bubbleSoftTeacherId(List head){ ?? ?Teacher T; ? ? int n=0; ? ? List current=head,record; ?? ?//統(tǒng)計(jì)一共有多少人數(shù) ? ? while(current){ ? ? ? ? n++; ? ? ? ? current=current->next; ? ? } ?? ?current=head;? ?? ?//排序 ? ? for(int i=0;i next){ ?? ??? ??? ?record=current->next; ?? ??? ??? ?if(record->self.getTeacherId() self.getTeacherId()){ ?? ??? ??? ??? ?T=record->self; ?? ??? ??? ??? ?record->self=current->self; ?? ??? ??? ??? ?current->self=T; ?? ??? ??? ?}? ?? ??? ??? ?current=current->next; ? ? ? ? } ?? ??? ?current=head;? ? ? } ? ? return head; } //基于冒泡排序的根據(jù)教師工資排序 List bubbleSoftSalary(List head){ ?? ?Teacher T; ? ? int n=0; ? ? List current=head,record; ?? ?//統(tǒng)計(jì)一共有多少人數(shù) ? ? while(current){ ? ? ? ? n++; ? ? ? ? current=current->next; ? ? } ?? ?current=head;? ?? ?//排序//排序 ? ? for(int i=0;i next){ ?? ??? ??? ?record=current->next; ?? ??? ??? ?if(record->self.getSalary() self.getSalary()){ ?? ??? ??? ??? ?T=record->self; ?? ??? ??? ??? ?record->self=current->self; ?? ??? ??? ??? ?current->self=T; ?? ??? ??? ?}? ?? ??? ??? ?current=current->next; ? ? ? ? } ?? ??? ?current=head;? ? ? } ? ? return head; }
教師類定義代碼如下
.h文件
#ifndef TEACHERMESSAGE #define TEACHERMESSAGE #include"stdc++.h" using namespace std; //課程類 class Lesson{ ? ? private: ? ? string LesName; ? ? string Point; ? ? public: ? ? Lesson(){} ? ? ~Lesson(){} ? ? public: ? ? //傳輸數(shù)據(jù) ? ? void getData(string LesName,string Point); ? ? //輸出樣式 ? ? void LesInterFace(); ? ? //更改課程名稱 ?? ?void changeLesName(string LesName); ? ? //更改學(xué)分 ?? ?void changePoint(string Point); ? ? //獲取課程名稱 ?? ?string getLesName(); ? ? //獲取學(xué)分 ?? ?string getPoint(); }; //人員類 class Person{ ? ? ? ? protected: ? ? ? ? string Name; ? ? ? ? string Identify; ? ? ? ? string Age; ?? ??? ?Lesson course; ? ? ? ? public: ? ? ? ?? ? ? ? ? Person(){} ? ? ? ? ~Person(){} ? ? ? ? public: ?? ??? ?//傳輸數(shù)據(jù) ? ? ? ? void getData(string Name,string Identity,string Age,Lesson course); ?? ??? ?//輸出數(shù)據(jù) ? ? ? ? void showmessage(); ?? ??? ?//更改姓名 ? ? ? ? void changeName(string name); ?? ??? ?//更改身份證 ? ? ? ? void changeIdentify(string Identify); ?? ??? ?//更改年齡 ? ? ? ? void changeAge(string Age); ?? ??? ?//更改課程名稱 ?? ??? ?void changeCoureseLesName(string LesName); ?? ??? ?void changeCouresePoint(string Point); ?? ??? ?//獲取姓名 ?? ??? ?string getName(); ?? ??? ?//獲取身份證號 ?? ??? ?string getIdentify(); ?? ??? ?//獲取年齡 ?? ??? ?string getAge(); ?? ??? ?//獲取課程名稱 ?? ??? ?string getCourseLesName(); ? ? }; //教師類 class Teacher:public Person{ ? ? protected: ? ? string teacherId; ? ? string salary; ? ? public: ? ? Teacher(){} ? ? ~Teacher(){} ? ? public: ?? ?//傳輸數(shù)據(jù) ? ? void getData(string Name,string Identity,string Age,string teacherId,string salary,Lesson course); ?? ?//輸出 ? ? void showmessage(); ?? ?//更改教師工號 ? ? void changeTeacherId(string teacherId); ?? ?//更改工資 ? ? void changeSalary(string salary); ?? ?//獲取教師工號 ?? ?string getTeacherId(); ?? ?//獲取工資 ?? ?string getSalary(); }; #endif
.cpp文件
#include"teacherMessage.h" //傳輸數(shù)據(jù) void Person::getData(string Name,string Identity,string Age,Lesson course){ ? ? this->Name=Name; ? ? this->Identify=Identity; ? ? this->Age=Age; ?? ?this->course=course; } //輸出數(shù)據(jù) void Person::showmessage(){ ? ? cout<<" "<Name<<" ? ? ?"< Identify<<" ? ? ? ? ? ? "< Age; } //更改姓名 void Person::changeName(string Name){ ? ? this->Name=Name; } //更改身份證 void Person::changeIdentify(string Identify){ ? ? this->Identify=Identify; } //更改年齡 void Person::changeAge(string Age){ ? ? this->Age=Age; } //更改課程名稱 void Person::changeCoureseLesName(string LesName){ ?? ?this->course.changeLesName(LesName); } void Person::changeCouresePoint(string Point){ ?? ?this->course.changePoint(Point); } //獲取年齡 string Person::getAge(){ ?? ?return this->Age; } //獲取姓名 string Person::getName(){ ?? ?return this->Name; } //獲取身份證號 string Person::getIdentify(){ ?? ?return this->Identify; } //獲取課程名稱 string Person::getCourseLesName(){ ?? ?return this->course.getLesName(); } //傳輸數(shù)據(jù) void Teacher::getData(string Name,string Identity,string Age,string teacherId,string salary,Lesson course){ ? ? Person::getData(Name,Identity,Age,course); ? ? this->teacherId=teacherId; ? ? this->salary=salary; } //輸出 void Teacher::showmessage(){ ? ? Person::showmessage(); ? ? cout<<" ? ? "< course.LesInterFace(); } //更改工資 void Teacher::changeSalary(string salary){ ? ? this->salary=salary; } //更改教師工號 void Teacher::changeTeacherId(string teacherId){ ? ? this->teacherId=teacherId; } //獲取教師工號 string Teacher::getTeacherId(){ ?? ?return this->teacherId; } //獲取工資 string Teacher::getSalary(){ ?? ?return this->salary; } void Lesson::getData(string LesName,string Point){ ?? ?this->LesName=LesName; ?? ?this->Point=Point; } void Lesson::changeLesName(string LesName){ ?? ?this->LesName=LesName; } void Lesson::changePoint(string Point){ ?? ?this->Point=Point; } string Lesson::getLesName(){ ?? ?return this->LesName; } string Lesson::getPoint(){ ?? ?return this->Point; } void Lesson::LesInterFace(){ ?? ?cout< LesName<<" ? ? ?"< Point; }
程序已經(jīng)基本完成,但是不知道為什么在文件讀入那邊讀取第二次時(shí)程序會崩潰,這個(gè)問題亟待解決。
這個(gè)問題已經(jīng)解決,是之前的代碼在讀取第二次的時(shí)候還是從head開始,導(dǎo)致一個(gè)空間被分配了兩次,這樣是不行,修改代碼以后程序能正常運(yùn)行了。現(xiàn)在的代碼都是正確代碼。
這個(gè)程序?qū)懥藘商欤悴簧虾荛L,但是也不短了,這其實(shí)是一個(gè)很簡單的程序,主要是使用vs code來寫,然后用VC6.0進(jìn)行編譯,很多問題沒辦法一下子找到,要慢慢的去一個(gè)地方一個(gè)地方的測試,花費(fèi)了很多時(shí)間,幾個(gè)比較復(fù)雜的功能完成以后,后面就駕輕就熟了,這個(gè)程序算是第二次寫,之前有說要用更好的方法完成,確實(shí)也做到了,雖然不是很完善,不過下一次就打算使用QT來寫圖形界面程序。
原文鏈接:https://blog.csdn.net/TeqGin/article/details/92760558
相關(guān)推薦
- 2022-06-12 C語言數(shù)據(jù)結(jié)構(gòu)中堆排序的分析總結(jié)_C 語言
- 2023-02-27 C語言中互斥鎖與自旋鎖及原子操作使用淺析_C 語言
- 2022-05-05 Python學(xué)習(xí)之字典的常用方法總結(jié)_python
- 2022-06-23 詳解windows?server?2012的DHCP保留地址導(dǎo)出導(dǎo)入、DHCP故障轉(zhuǎn)移配置、DNS條
- 2022-04-14 解決Mac環(huán)境下zsh: command not found:
- 2022-11-14 python?numpy查詢定位賦值數(shù)值所在行列_python
- 2022-06-10 FreeRTOS進(jìn)階系統(tǒng)節(jié)拍時(shí)鐘示例的完全解析_操作系統(tǒng)
- 2023-01-27 C#實(shí)現(xiàn)拆分合并Word表格中的單元格_C#教程
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細(xì)win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運(yùn)行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運(yùn)算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認(rèn)證信息的處理
- Spring Security之認(rèn)證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯(cuò)誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實(shí)現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標(biāo)對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊(duì)列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠(yuǎn)程分支