VC++,利用了文本文件进行保存修改用户数据#include"iostream"#include"string"#include"fstream"#include"iomanip"usingnamespacestd;intcount1=0,count11=0;//学生总数和交钱的人数intcount2=0,count22=0;classStu{public: Stu(doublexwater=0,doublexpower=0,doublexgas=0,stringxnum="a",stringxna="a");//学生类构造函数voidoperator=(StuS);//赋值运算符重载 friendostream&operator<<(ostream&a,Stu&S)//插入运算符重载{ a<<setw(8)<<left<<; a<<setw(8)<<left<<;//输出时左对齐8位 a<<setw(8)<<left<<; a<<setw(8)<<left<<; a<<setw(8)<<left<<; a<<setw(8)<<left<<(); a<<setw(8)<<left<<(); a<<setw(8)<<left<<(); a<<setw(8)<<left<<();if(!=0)a<<"已交";elsea<<"未交";cout<<endl; returna; } doubleSGetW();//计算水费 doubleSGetC();//计算电费doubleSGetG();//计算煤气费doubleStotal();//计算总费用doublewater,power,gas,water_rate,circuit,gas_rate,total; intflag; stringnumber,name;};Stu::Stu(doublexwater,doublexpower,doublexgas,stringxnum,stringxna)//学生类构造函数{ water=xwater;power=xpower;gas=xgas;number=xnum;name=xna;flag=0; } voidStu::operator=(StuS)//赋值运算符重载 { name=; number=; water=; power=; gas=; } doubleStu::SGetW()//计算水费{if(water<10)water_rate=0;elsewater_rate=*(water-10);returnwater_rate;}doubleStu::SGetC()//计算电费{if(power<10)circuit=0;elsecircuit=*(power-10);returncircuit;}doubleStu::SGetG()//计算煤气费{if(gas<10)gas_rate=0;elsegas_rate=*(gas-10);returngas_rate;}doubleStu::Stotal()//计算总的钱{ total=SGetG()+SGetW()+SGetC(); returntotal; }//*************************************************************************************classarrayofStu//学生类计算{ public: arrayofStu(intsz=1){size=sz;student=newStu[size];}//构造函数 ~arrayofStu(){delete[]student;} voidxuesheng();//学生用户主菜单 voidjiaofei();//学生交费菜单 voidregist();//登记学生voidamend();//修改用户菜单voidadd();//增加用户 voiddelet();//删除用户菜单voidnad();//姓名删除voidnumd();//学号删除voidcheck();//查询菜单voidnacheck();//姓名查询voidnumcheck();//学号查询voidnaj();//输入姓名交费voidnumj();//输入学号交费voiddisplay();//查看交费情况voidsave(); private:intsize;Stu*student; };voidarrayofStu::regi
宿舍管理系统代码实现 来自淘豆网m.daumloan.com转载请标明出处.