C++직원 관리 시스템 실현

본 논문 의 사례 는 여러분 에 게 C++직원 관리 시스템 을 실현 하 는 구체 적 인 코드 를 공유 하여 여러분 께 참고 하 시기 바 랍 니 다.구체 적 인 내용 은 다음 과 같 습 니 다.

workermanager.h

#pragma once//         
#include <iostream>
#include "worker.h"
using namespace std;
#include "boss.h"
#include "employee.h"
#include "manager.h"

#include <fstream>
#define FILENAME "empFile.txt"

class WorkerManager
{
public:
 WorkerManager();

 void Show_Menu();//    

 void ExitSystem();//    

 int m_EmpNum;//      

 Worker ** m_EmpArray;//      

 void Add_Emp();//    

 void Del_Emp();//    

 void Find_Emp();//    

 void Mod_Emp();//    

 void Show_Emp();//    

 void Sort_Emp();//  

 void Clean_File();

 int IsExist(int id);//              ,             ,     -1

 void save();//    

 bool m_FileIsEmpty;//        ,  

 int get_EmpNum();//    

 void init_Emp();//       

 ~WorkerManager();
};
worker.h

#pragma once//         
#include <iostream>
#include <string>
using namespace std;
class Worker//     
{
public:
 //      
 virtual void showInfo() = 0;
 //      
 virtual string getDeptName() = 0;

 int m_Id;//    
 string m_Name;//    
 int m_DeptId;//         
};
employee.h

#pragma once
#include <iostream>
using namespace std;
#include "worker.h"

class Employee :public Worker
{
public:
 //    
 Employee(int id, string name, int dId);

 //      
 virtual void showInfo();

 //      
 virtual string  getDeptName();
};
manager.h

#pragma once
#include <iostream>
using namespace std;
#include "worker.h"

class Manager :public Worker
{
public:
 //    
 Manager (int id, string name, int dId);

 //      
 virtual void showInfo();

 //      
 virtual string  getDeptName();
};
boss.h

#pragma once
#include <iostream>
using namespace std;
#include "worker.h"

class Boss :public Worker
{
public: 
 Boss(int id, string name, int dId);
 virtual void showInfo();
 virtual string getDeptName();
};
직원 관리 시스템

#include <iostream>
using namespace std;
#include "WorkerManager.h"
#include "worker.h"
#include "employee.h"

int main()
{
 WorkerManager wm;//       
 int choice = 0;//    
 while (true)
 {
  //    
  wm.Show_Menu();
  cout << "       :" << endl;
  cin >> choice;
  switch (choice)
  {
  case 0://    
   wm.ExitSystem();
   break;
  case 1://    
   wm.Add_Emp();
   break;
  case 2://    
   wm.Del_Emp();
   break;
  case 3://    
   wm.Find_Emp();
   break;
  case 4://    
   wm.Mod_Emp();
   break;
  case 5://    
   wm.Show_Emp();
   break;
  case 6://    
   wm.Sort_Emp();
   break;
  case 7://    
   wm.Clean_File();
   system("cls");
   break;
  }
 }
 system("pause");
 return 0;
}
workermanager.cpp

#pragma once//         
#include <iostream>
#include "worker.h"
using namespace std;
#include "boss.h"
#include "employee.h"
#include "manager.h"

#include <fstream>
#define FILENAME "empFile.txt"

class WorkerManager
{
public:
 WorkerManager();

 void Show_Menu();//    

 void ExitSystem();//    

 int m_EmpNum;//      

 Worker ** m_EmpArray;//      

 void Add_Emp();//    

 void Del_Emp();//    

 void Find_Emp();//    

 void Mod_Emp();//    

 void Show_Emp();//    

 void Sort_Emp();//  

 void Clean_File();

 int IsExist(int id);//              ,             ,     -1

 void save();//    

 bool m_FileIsEmpty;//        ,  

 int get_EmpNum();//    

 void init_Emp();//       

 ~WorkerManager();
};
employee.cpp

#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::showInfo()
{
 cout << "    :" << this->m_Id
  << "\t    :" << this->m_Name
  << "\t  :" << getDeptName()
  << "\t    :         " << endl;
}

string Employee::getDeptName()
{
 return string("  "); 
}
manager.cpp

#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::showInfo()
{
 cout << "    :" << this->m_Id
  << "\t    :" << this->m_Name
  << "\t  :" << getDeptName()
  << "\t    :               " << endl;
}

string Manager::getDeptName()
{
 return string("  ");
}
boss.cpp

#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::showInfo()
{
 cout << "\t    :" << this->m_Id
  << "\t    :" << this->m_Name
  << "\t  :" << getDeptName()
  << "\t    :      " << endl;
}

string Boss::getDeptName()
{
 return string ("  ");
}

이상 이 바로 본 고의 모든 내용 입 니 다.여러분 의 학습 에 도움 이 되 고 저 희 를 많이 응원 해 주 셨 으 면 좋 겠 습 니 다.

좋은 웹페이지 즐겨찾기