C+++従業員管理システムの実現
ここの例では、C++従業員管理システムを実現するための具体的なコードを共有します。
workermanager.h
以上が本文の全部です。皆さんの勉強に役に立つように、私たちを応援してください。
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();
};
ウォーカー.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();
};
従業員管理システム.cpp
#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 (" ");
}
以上が本文の全部です。皆さんの勉強に役に立つように、私たちを応援してください。