【文件属性】:
文件名称:c++职工记录表
文件大小:5KB
文件格式:CPP
更新时间:2019-05-13 08:26:37
c++ 职工 记录表
#include
#include
#include
#include
#include
#include
#include
using namespace std;
class Employee{
protected:
int number;
string name;
public:
Employee(){}
Employee(int num,string nam);
void setname(string n);
void setnumber(int n);
string getname(void);
int getnumber(void);
virtual void display(void);
friend bool less_number(const Employee & m1, const Employee & m2);
};
class EmployeeDetial:public Employee{
protected:
string sex;
int age;
public:
EmployeeDetial(){}
EmployeeDetial(int num,string nam,string se,int ag);
void setsex (string s);
void setage(int a);
string getsex(void);
int getage(void);
void display(void);
friend bool less_age(const EmployeeDetial & m1, const EmployeeDetial & m2);
};
void Employee::setname(string n){
name=n;
}
void Employee::setnumber(int n){
number=n;
}
string Employee::getname(void){
return name;
}
int Employee::getnumber(void){
return number;
}
void Employee::display(void){
// cout<<"E.display"< vED;
vector vE;
void load_f_ED(){
int num,age;
string name,sex;
ifstream fin("EmployeeDetial.txt");
if(!fin){
cout<<"open file error!"<>num>>name>>sex>>age){
// fin>>num>>name>>sex>>age;
vED.push_back(EmployeeDetial(num,name,sex,age));
counter++;
}
fin.close();
}
bool load_f_E(){
int num;
string name;
ifstream fin("Employee.txt");
if(!fin)return false;
while(fin>>num>>name){
// fin>>num>>name>>sex>>age;
vE.push_back(Employee(num,name));
}
fin.close();
return true;
}
void display_E(){
for(int i=0;i>num;
cout<<"input the name:"<>name;
cout<<"input the sex:"<>sex;
cout<<"input the age:"<>age;
vED.push_back(EmployeeDetial(num,name,sex,age));
vE.push_back(Employee(num,name));
counter++;
cout<<"add success!"<>a;
for(int i=0;i>a;
return a;
}
void ED_sort_age(){
sort(vED.begin(), vED.end(), less_age);
}
void ED_sort_number(){
sort(vED.begin(), vED.end(), less_number);
}
void E_sort_number(){
sort(vE.begin(), vE.end(), less_number);
}
int main(){
int a=dd();
while(a!=8){
load_f_ED();
if(!load_f_E())E_ED();
switch(a){
case 1: add();break;
case 2:delet();break;
case 3: E_fout();cout<<"success!"<>a;
if(1==a){ED_sort_number();display_ED();break;}
if(2==a){ED_sort_age();display_ED();break;}
case 7:E_sort_number();display_E();break;
default:cout<<"what are you doing?"<