开发工具:
文件大小: 447kb
下载次数: 0
上传时间: 2012-04-05
详细说明: 通过C++实习简单的设计出图书管理系统 class Student { private: int snumber; string sname; string ssex; int sage; string sdapt; string srutime; string sbiyetime; string sjieyuetime; int sjiecount; public: Student(int number=0,string name="0",string sex="0",int age=0,string dapt="0", string rutime="0",string biyetime="0",string jieyuetime="0",int jiecount=0); virtual ~Student(); int Getsnumber(); void Setsnumber(int number); string Gets name(); void Setsname(string name); string Getssex(); void Setssex(string sex); int Getsage(); void Setsage(int age); string Getsdapt(); void Setsdapt(string dapt); string Getsrutime(); void Setsrutime(string rutime); string Getsbiyetime(); void Setsbiyetime(string biyetime); string Getsjieyuetime(); void Setsjieyuetime(string jieyutime); int Getsjiecount(); void Setsjiecount(int jiecount); void Studentshow(); }; 2)将文本文件信息存入Stulist容器 int snumber; string sname; string ssex; int sage; string sdapt; string srutime; string sbiyetime; string sjieyuetime; int sjiecount; //定义Stulist容器和相应迭代器 list Stulist; list::iterator s_iter=Stulist.begin(); list::iterator iter=Stulist.begin(); //定义文件输入流,读取文件 ifstream infile2; infile2.open("Student.txt",ios::in); //将文本文件信息存入Stulist容器中 infile2>>snumber>>sname>>ssex>>sage>>sdapt>>srutime>>sbiyetime>>sjieyuetime>> sjiecount; Student std(snumber,sname,ssex,sage,sdapt,srutime,sbiyetime,sjieyuetime,sjiecount); Stulist.push_back(std); while(infile2>>snumber>>sname>>ssex>>sage>>sdapt>>srutime>>sbiyetime>>sjieyuet ime>>sjiecount) { Student std(snumber,sname,ssex,sage,sdapt,srutime,sbiyetime,sjieyuetime, sjiecount); Stulist.push_back(std); } 3)查询学生信息 cout<<"1、显示所有信息\t\t2、查询某个学生"<>xuan; if(xuan==1) { cout<<"全部学生信息如下:"<Studentshow(); } } else if(xuan==2) { cout<<"请输入您要查询学生的编号(20100128**)->>"; int xuehao; int judge=0; cin>>xuehao; for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++) { if(s_iter->Getsnumber()==xuehao) { cout<<"查询结果如下:"<Studentshow(); judge=1; break; } } if(judge == 0) { cout<<"你要查找的学生不存在!"<>"; int number; int judge=0; int ok=0; cin>>number; for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++) { if(s_iter->Getsnumber()==number) { iter=s_iter; iter->Studentshow(); judge=1; break; } else{;} } cout<<"是否删除:1、是2、否->>"; cin>>ok; if(judge==1 && ok==1) { Stulist.erase(s_iter); ofstream Delestu; Delestu.open("Student.txt",ios::out); for(s_iter=Stulist.begin(); s_iter!=Stulist.end(); s_iter++) { Delestu<Getsnumber()<<""<Getsname()<<""< Getssex()<<""<Getsage()<<""<Getsdapt()<<""< Getsrutime()<<""<Getsbiyetime()<<""<Getsjieyuetime() <<""<Getsjiecount()<
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.