c++ 基础知识-类与对象-实践-员工管理系统(记录)1
1.员工基类
#pragma once
#ifndef _WORKER_
#define _WORKER_
#include <iostream>
using namespace std;
class Worker
{
public:
virtual void Show_Info() = 0;
virtual string Get_Dept_Name() = 0;
public:
int m_Id;
string m_Name;
int m_DeptId;
};
#endif
2.员工类-普通员工
#pragma once
#ifndef _EMPLOYEE_
#define _EMPLOYEE_
#include <iostream>
#include <string>
#include "worker.h"
using namespace std;
class Employee:public Worker
{
public:
Employee(int id,string name,int dId);
virtual void Show_Info();
virtual string Get_Dept_Name();
};
#endif
#include "employee.h"
Employee::Employee(int id,string name,int dId)
{
this->m_Id = id;
this->m_Name = name;
this->m_DeptId = dId;
}
void Employee::Show_Info()
{
cout<<"职工编号: "<<this->m_Id
<<"\t职工姓名: "<<this->m_Name
<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}
string Employee::Get_Dept_Name()
{
return string("员工");
}
3.员工类-经理
#pragma once
#ifndef _MANAGER_
#define _MANAGER_
#include <iostream>
#include <string>
#include "worker.h"
using namespace std;
class Manager:public Worker
{
public:
Manager(int id,string name,int dId);
virtual void Show_Info();
virtual string Get_Dept_Name();
};
#endif
#include "manager.h"
Manager::Manager(int id,string name,int dId)
{
this->m_Id = id;
this->m_Name = name;
this->m_DeptId = dId;
}
void Manager::Show_Info()
{
cout<<"职工编号: "<<this->m_Id
<<"\t职工姓名: "<<this->m_Name
<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}
string Manager::Get_Dept_Name()
{
return string("经理");
}
3.员工类-老板
#pragma once
#ifndef _BOSS_
#define _BOSS_
#include <iostream>
#include <string>
#include "worker.h"
using namespace std;
class Boss:public Worker
{
public:
Boss(int id,string name,int dId);
virtual void Show_Info();
virtual string Get_Dept_Name();
};
#endif
#include "boss.h"
Boss::Boss(int id,string name,int dId)
{
this->m_Id = id;
this->m_Name = name;
this->m_DeptId = dId;
}
void Boss::Show_Info()
{
cout<<"职工编号: "<<this->m_Id
<<"\t职工姓名: "<<this->m_Name
<<"\t岗位: "<<this->Get_Dept_Name()<<endl;
}
string Boss::Get_Dept_Name()
{
return string("老板");
}