出现有关问题了 不能解决 小弟我很急 那个前辈指点以下
出现问题了 不能解决 我很急 那个前辈指点以下
在 运行第一次的时候 没有问题 你先输入点信息 等第二遍了你删掉 刚才的写如文件就是把 ofstream out2("学生信息.dat");
for (it_s=total_student.begin();it_s!=total_student.end();it_s++)
{
// cout < <(*it_s).name < <" " < <(*it_s).xuehao < <endl;
out2.write((char*)&(*it_s),sizeof(Student));
}
out2.close(); 删掉
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <conio.h>
#include <list>
using namespace std;
class Subject
{
public:
string name,kechenghao,xingzhi;
int zongkeshi,shouke;
double xuefen;
int total,now;
}sub;
class Guanliyuan ///用来管理老师,管理员最多2个
{
public:
void tianjialaoshi(); //添加老师
void shanchulaoshi(); //删除老师
void tianjiaxuesheng();//添加学生
void shanchuxuesheng();//删除学生
void xiugaimima();
int xinxihedui(string hao,string mi); //身份验证
//private:
string guanlihao,password;
} gl[2];
class Teacher //一个老师一门课程,
{
public:
friend class Student;
friend Guanliyuan;
void tianxiechengji(); //输入成绩
void chakanxuesheng(); //查看学生
void chengjipaixu(); //成绩排序
void xiugaichengji(); //修改成绩
void xiugaimima(); //修改密码
void genggaixuefen();//更改学分
int xinxihedui(string &na,string &mi);
Subject subj;
//private:
string password,name;
}t;
list <Teacher> total_teacher;
list <Teacher>::iterator it_t;
class Student //一个学生
{
public:
friend Guanliyuan;
friend Teacher;
void xuanke();//选课
void chengjichaxun();//成绩查询 包含排名
void kechengchaxun();//对以选课的查询
int xinxihedui(long &l,string &n); //信息核对 返回0 则什么也不对,返回1 学号对,
//2姓名对,3完全对
//private:
class Danke:public Subject
{
public:
double chengji;
}subj_1[10];
long xuehao;
string name;
}s;
list <Student> total_student;
list <Student>::iterator it_s;
void main()
{
string k;
int i=0;
while (1)
{
i++;
system("cls");
if(i!=1)cout < <"\n\n\t添加成功!当不需要添加时在姓名项输入'0'即可!";
cout < <"\n\n\t\t\t输入学生的姓名:";
cin>>k;
if (k=="0")
{
break;
}
s.name=k;
cout < <"\n\n\t\t\t输入学生的学号:";
cin>>s.xuehao;
total_student.push_back(s);
}
ofstream out2("学生信息.dat");
for (it_s=total_student.begin();it_s!=total_student.end();it_s++)
{
// cout < <(*it_s).name < <" " < <(*it_s).xuehao < <endl;
out2.write((char*)&(*it_s),sizeof(Student));
}
out2.close();
// total_student.clear();
total_student.push_front(s);
ifstream in2("学生信息.dat",ios::in ¦ios::binary);
while(in2.read((char*)&s,sizeof(Student)))
total_student.push_front(s);
在 运行第一次的时候 没有问题 你先输入点信息 等第二遍了你删掉 刚才的写如文件就是把 ofstream out2("学生信息.dat");
for (it_s=total_student.begin();it_s!=total_student.end();it_s++)
{
// cout < <(*it_s).name < <" " < <(*it_s).xuehao < <endl;
out2.write((char*)&(*it_s),sizeof(Student));
}
out2.close(); 删掉
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
#include <fstream>
#include <conio.h>
#include <list>
using namespace std;
class Subject
{
public:
string name,kechenghao,xingzhi;
int zongkeshi,shouke;
double xuefen;
int total,now;
}sub;
class Guanliyuan ///用来管理老师,管理员最多2个
{
public:
void tianjialaoshi(); //添加老师
void shanchulaoshi(); //删除老师
void tianjiaxuesheng();//添加学生
void shanchuxuesheng();//删除学生
void xiugaimima();
int xinxihedui(string hao,string mi); //身份验证
//private:
string guanlihao,password;
} gl[2];
class Teacher //一个老师一门课程,
{
public:
friend class Student;
friend Guanliyuan;
void tianxiechengji(); //输入成绩
void chakanxuesheng(); //查看学生
void chengjipaixu(); //成绩排序
void xiugaichengji(); //修改成绩
void xiugaimima(); //修改密码
void genggaixuefen();//更改学分
int xinxihedui(string &na,string &mi);
Subject subj;
//private:
string password,name;
}t;
list <Teacher> total_teacher;
list <Teacher>::iterator it_t;
class Student //一个学生
{
public:
friend Guanliyuan;
friend Teacher;
void xuanke();//选课
void chengjichaxun();//成绩查询 包含排名
void kechengchaxun();//对以选课的查询
int xinxihedui(long &l,string &n); //信息核对 返回0 则什么也不对,返回1 学号对,
//2姓名对,3完全对
//private:
class Danke:public Subject
{
public:
double chengji;
}subj_1[10];
long xuehao;
string name;
}s;
list <Student> total_student;
list <Student>::iterator it_s;
void main()
{
string k;
int i=0;
while (1)
{
i++;
system("cls");
if(i!=1)cout < <"\n\n\t添加成功!当不需要添加时在姓名项输入'0'即可!";
cout < <"\n\n\t\t\t输入学生的姓名:";
cin>>k;
if (k=="0")
{
break;
}
s.name=k;
cout < <"\n\n\t\t\t输入学生的学号:";
cin>>s.xuehao;
total_student.push_back(s);
}
ofstream out2("学生信息.dat");
for (it_s=total_student.begin();it_s!=total_student.end();it_s++)
{
// cout < <(*it_s).name < <" " < <(*it_s).xuehao < <endl;
out2.write((char*)&(*it_s),sizeof(Student));
}
out2.close();
// total_student.clear();
total_student.push_front(s);
ifstream in2("学生信息.dat",ios::in ¦ios::binary);
while(in2.read((char*)&s,sizeof(Student)))
total_student.push_front(s);