/* 2014/05/27 學(xué)生信息管理系統(tǒng)源碼(面向?qū)ο笤O(shè)計(jì)c++) for act_head*/一、#ifndef _ACT_H#define _ACT_H#include"std.h"using namespace std;class Act{private: int top;//數(shù)組下表指示器 Student std[1000]; public: void add(); void display(); void del(); void query(); Student *querybynum(long num); Student *querybyname(char name[]); void modif();};ostream& operator<<( ostream& os, Student& t ) { long num; string name;//! //char name[50];//error! char sex,c='y'; int age; int tag; num=t.getnum(); name=t.getname(); sex=t.getsex(); age=t.getage(); tag=t.gettag(); os << num <<' '<< name<<' '<> operator.istream& operator>>( istream& is, Student& t ) { long num; char name[50]; char sex,c='y'; int age; int tag; is>>num>>name>>sex>>age>>tag; t.setnum(num); t.setname(name); t.setsex(sex); t.setage(age); t.settag(); return is ;}void Act::add(){ Student s,s1; long num; char name[50]; char sex,c='y'; int age; int tag; ofstream file("std.txt",ios::app);//追加!不同于ate!打開(kāi)一個(gè)輸出文件用于在文件尾添加數(shù)據(jù) while(1) { cout<<"請(qǐng)輸入一個(gè)學(xué)生信息:(學(xué)號(hào)、姓名、性別(W:代表女性woman,M:代表男性man)、年齡)"; //file>>s; cin>>num>>name>>sex>>age; s.setnum(num); s.setname(name); s.setsex(sex); s.setage(age); s.settag(); file<>c; if(c=='n'||c=='N') break; } file.close(); }void Act::display(){ top=-1; Student s[1000],s1;//s[n],n不能太大! ifstream file("std.txt"); //fstream file("d:\\std.txt",ios_base::out); while(1) { //file.read((char*)&s,sizeof(s)); // file.read(reinterpret_cast(&s),sizeof(s)); file>>s1; if(!file.eof()) break;//安排位置要注意,以防多輸出隨機(jī)數(shù)據(jù) top++; cout<<"\t\t第"<>c2; switch(c2) { case 1: cout<<"請(qǐng)輸入要查詢的學(xué)生的學(xué)號(hào): "; long num; cin>>num; s=querybynum(num); if(s==NULL) cout<<"在文件中不含有該生信息..."<display(); break; } case 2: cout<<"請(qǐng)輸入要查詢的學(xué)生的姓名: "; char name[50]; cin>>name; s=querybyname(name); if(s==NULL) cout<<"在文件中不含有該生信息..."<display(); break; default: cout<<"輸入有誤!請(qǐng)重新輸入!\n"; break; }}//根據(jù)指定學(xué)號(hào)進(jìn)行查找Student *Act::querybynum(long num){ int top=-1; Student s; //cout<<"hehe"<>s; while(!file.eof()) { //file.read((char*)&s,sizeof(s)); file>>s; top++; //cout<>s; if(!file) break; top++; std[top]=s; } file.close(); for(int i=0;i<=top;i++) if(strcmp(std[i].getname(),name)==0&&std[i].gettag()==0) return &std[i]; return NULL;//找不到,返回一個(gè)NULL值} void Act::modif(){ long num; char name[50]; char sex; int age; Student* s; char yn;//y or n cout<<"請(qǐng)輸入要修改學(xué)生的學(xué)號(hào): "<>num; s=querybynum(num); if(s==NULL) cout<<"在數(shù)據(jù)庫(kù)中不含有該生信息..."<>yn; if(yn=='Y'||yn=='y') { cout<<"請(qǐng)輸入學(xué)生的新學(xué)號(hào):"<>num; s->setnum(num); } cout<<"學(xué)生的姓名是否需被修改?(y/n)"<>yn; if(yn=='Y'||yn=='y') { cout<<"請(qǐng)輸入學(xué)生的新姓名:"<>name; s->setname(name); } cout<<"學(xué)生的性別是否需被修改?(y/n)"<>yn; if(yn=='Y'||yn=='y') { cout<<"請(qǐng)輸入學(xué)生的新性別:"<>sex; s->setsex(sex); } cout<<"學(xué)生的年齡是否需被修改?(y/n)"<>yn; if(yn=='Y'||yn=='y') { cout<<"請(qǐng)輸入學(xué)生的新年齡:"<>age; s->setage(age); } cout<<"學(xué)生信息修改完畢,修改后的信息如下:\n\n\n"; cout<display(); //file<<*s//error! //老師,文件的輸出,修改后的數(shù)據(jù)該如何輸出,指針不是很會(huì)用誒 ofstream file("std.txt"); for(int i=0;i<=to。