Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <set>
- using namespace std;
- class worker {
- public:
- worker(string name, int salary, int id) : name_(name), salary_(salary), id_(id) {}
- void set_name(const string& name) {
- name_ = name;
- }
- string get_name() {
- return name_;
- }
- void set_salary(int salary) {
- salary_ = salary;
- }
- int get_salary() {
- return salary_;
- }
- void set_id(int id) {
- id_ = id;
- }
- int get_id() {
- return id_;
- }
- virtual void work() = 0;
- private:
- string name_;
- int salary_;
- int id_;
- };
- class programmer : public worker {
- public:
- programmer(string name, int salary, int id) : worker(name, salary, id) {}
- void add_project(string project_name) {
- projects_.insert(project_name);
- }
- void del_project(string project_name) {
- projects_.erase(project_name);
- }
- int get_project_number() {
- return projects_.size();
- }
- void work() override {
- cout << "Я пишу код" << endl;
- }
- private:
- set<string> projects_;
- };
- class manager : public worker {
- public:
- manager(string name, int salary, int id, string department_name, int employees_number) : worker(name, salary, id), department_name_(department_name), employees_number_(employees_number) {}
- int get_employees_number() {
- return employees_number_;
- }
- void set_department_name(string name) {
- department_name_ = name;
- }
- string get_department_name() {
- return department_name_;
- }
- void work() override {
- cout << "Я руковожу" << endl;
- }
- private:
- string department_name_;
- int employees_number_;
- };
- int main() {
- setlocale(LC_ALL, "ru");
- programmer pr("Иван", 1000, 12356733);
- manager mn("Оля", 2000, 12356741, "Отдел разработки", 10);
- pr.add_project("Калькулятор");
- cout << pr.get_project_number() << endl;
- cout << mn.get_department_name() << endl;
- mn.work();
- pr.work();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement