QtDesignPatterns/compositepattern/employee.h

36 lines
821 B
C
Raw Normal View History

2024-02-06 17:21:37 +08:00
#include <string>
#include <vector>
#include <iostream>
using namespace std;
class Employee
{
public:
Employee(string name, string department, int salary)
{
this->name = name;
this->department = department;
this->salary = salary;
cout << "Employee name: " + name << ", department: " + department << ", salary: " << salary << endl;
}
void add(Employee *employee)
{
vector.push_back(employee);
}
std::vector<Employee*> getVector()
{
return this->vector;
}
string getDetails()
{
string ret = "Employee name: " + name + ", department: " + department + ", salary: " + std::to_string(salary);
return ret;
}
private:
string name;
string department;
int salary;
std::vector<Employee *> vector;
};