Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "Windows.h"
- using namespace std;
- class Employee
- {
- public:
- Employee() : name("dafault"), id(0) {}
- Employee(string name, int id) : name(name), id(id) {}
- ~Employee() {}
- string getName() { return name; }
- int getId() { return id; }
- void setName(string name) { this->name = name; }
- void setId(int id) { this->id = id; }
- void show() { cout << id << " > " << name + "." << endl; }
- protected:
- string name;
- int id;
- };
- class Manager : public Employee
- {
- public:
- Manager() : Employee(), position("default"), fitnessTaxes(0) {}
- Manager(string name, int id, string position, double fitnessTaxes) : Employee(name, id), position(position), fitnessTaxes(fitnessTaxes) {}
- ~Manager() {}
- string getPosition() { return position; }
- double getFitnessTaxes() { return fitnessTaxes; }
- void setPosition(string position) { this->position = position; }
- void setFitnessTaxes(double fitnessTaxes) { this->fitnessTaxes = fitnessTaxes; }
- void show() { cout << id << " > " << name + ", " + position + " pays for fitness " << fitnessTaxes << " bucks." << endl; }
- protected:
- string position;
- double fitnessTaxes;
- };
- class Scientist : public Employee
- {
- public:
- Scientist() : Employee(), amountOfArticles(0) {}
- Scientist(string name, int id, int amountOfArticles) : Employee(name, id), amountOfArticles(amountOfArticles) {}
- ~Scientist() {}
- int getAmountOfArticles() { return amountOfArticles; }
- void setAmountOfArticles(int amountOfArticles) { this->amountOfArticles = amountOfArticles; }
- void show() { cout << id << " > " << name + ", published " << amountOfArticles << " articles." << endl; }
- protected:
- int amountOfArticles;
- };
- class Worker : public Employee
- {
- public:
- Worker() { Employee(); }
- Worker(string name, int id) : Employee(name, id) {}
- void show() { cout << id << " > " << name + " is a bricklayer, works for three days, without salary!!!" << endl; }
- ~Worker() {}
- };
- class Tmp
- {
- public:
- // What's why you should be carefull using initialisation lists
- // x = y will done first, but y is still unititialised
- // y = 1 will done second cause of class fields order ("int x" is wrote before "int y")
- Tmp(int x, int y) : y(1), x(this->y) { cout << endl << "x = " << this->x << endl << "y = " << this->y << endl; }
- private:
- int x;
- int y;
- };
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- Employee * e = new Employee("Todd Howard", 0);
- e->show();
- Manager * m = new Manager("Kim Chen In", 1, "the dictator", 300);
- m->show();
- Scientist * s = new Scientist("Popov", 2, 150);
- s->show();
- Worker * w = new Worker("Rabotyaga", 3);
- w->show();
- //Tmp * tmp = new Tmp(1, 2);
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement