员工信息管理
#include "Chairman.h"
void Chairman::input()
{cout << "请输入主任工程师的信息:" << endl << "职务、部门、专业、职称、编号、姓名、年龄:";
cin >> this->zhiwu >> this->department >> this->major
>>this->zhicheng>> this->number >> this->name >> this->age;
Write(*this);}//提示用户输入信息
void Chairman::write(fstream &m)
{m.open("Chairman.txt", ios::app);
m << "\t" << zhiwu << "\t" << department << "\t" << major << "\t" << zhicheng
<< "\t" << number << "\t" << name << "\t" << age<<endl;
m.close();}//写入文件
void Chairman::read(fstream &n)
{n.open("Chairman.txt", ios::in);
if (!n.is_open())
{cout << "文件打开失败" << endl;
system("pause");
return;}
cout << "主任工程师:"<< "\t职务\t"<<"部门\t"<<"专业\t"
<<"职称\t"<<"编号\t"<<"姓名\t"<<"年龄" << endl;
n >> this->zhicheng >> this->department >> this->major >>
this->zhicheng >> this->number >> this->name >> this->age;
while (!n.eof())
{cout << "\t\t" << this->zhicheng << "\t" << this->department << "\t"
<< this->major << "\t" << this->zhicheng << "\t"
<< this->number << "\t" << this->name << "\t" << this->age << endl;
n >> this->zhicheng >> this->department >> this->major >> this->zhicheng >> this->number >> this->name >> this->age;}
n.close();}//读取文件
void Chairman::display()
{Read(*this);}//输出文件的内容
评论