学生信息管理系统C++代码.doc
《学生信息管理系统C++代码.doc》由会员分享,可在线阅读,更多相关《学生信息管理系统C++代码.doc(13页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1. 程序执行后的部分效果1.1项目主菜单效果图1。2初始化信息,第一次对信息的录入1。3添加学生信息1。4删除某学生信息1。5修改某学生信息1。6查询某学生信息1。7显示全部学生信息源代码:/把StudentData。cpp(源代码) 和 student.txt(数据存放处)放在同一个文件夹下/include iostream#include stringinclude fstreaminclude stringinclude iomanipusing namespace std;/最多提供50个学生的数据,可根据需要进行更改const int MAX = 50;int count = 0;
2、/用来统计学生人数class Student public:void Set();/初始化信息,第一次对信息的录入void Add();/添加学生信息/从磁盘读取数据以便 进行 数据的操作,方便再重写进磁盘friend void Read(string no,string name,string sex,string special,string clas);int Judge(string num);/判断 num 是否在学生信息数据库中(注意它有一个参数,并且有一个int型的返回值)void Delete();/删除某学生信息void Change();/修改某学生信息 void Sear
3、ch();/查询某学生信息void Display();/显示全部学生信息private:string m_no;string m_name;string m_sex;/m_ 指的是成员变量(member)string m_special;string m_clas;;void Student:Set()string no, name, sex, special, clas;ofstream outfile(”student。txt); /打开文件if(!outfile)cerr” open errorendl;exit(1);/退出程序cout”当学号输入为 0 时,停止输入!”endl;c
4、out”请依次输入学生的学号,姓名,性别,专业,班级:endl;for(int i=0; iMAX; i+)cout第”count+1个学生:”no;if(no = ”0) break;/当输入的学号是 0 时,停止录入cinnamesexspecialclas;count+;m_no = no;outfilem_no”t”;/每录入一个学号,写进磁盘保存,以下同理m_name = name;outfilem_name”t”;m_sex = sex;outfilem_sext;m_special = special;outfilem_special”t”;m_clas = clas;outfi
5、lem_clasendl;outfile。close();/添加学生信息void Student::Add()string no, name, sex, special, clas;/以追加的方式录入信息,直接将信息追加到以前文件的末尾ofstream outfile(”student。txt”,ios:app);if(!outfile) cerr open error”endl; exit(1); count+;/添加一个学生信息,当然 count 要 +1cout”请依次输入要添加的学生学号,姓名,性别,专业,班级:”nonamesexspecialclas;m_no = no;outfi
6、lem_not”;m_name = name;outfilem_namet”;m_sex = sex;outfilem_sex”t”;m_special = special;outfilem_specialt”;m_clas = clas;outfilem_clasendl;outfile。close();cout已添加成功!endl;/从磁盘读取数据void Read(string no,string name,string sex,string special,string clas)ifstream infile(”student。txt”,ios:in);if(!infile)cerr
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 学生 信息管理 系统 C+ 代码
限制150内