Advertisement
MasterGun

Untitled

May 9th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. class Employee {
  5. public:
  6.     virtual double countup() = 0;
  7. };
  8. class Employee1 : public Employee {
  9.     int salary;
  10. public:
  11.     Employee1(int salary) {
  12.         this->salary = salary;
  13.     };
  14.     virtual double countup() override { return salary; };
  15. };
  16. class Employee2 :public Employee {
  17.     int wage;
  18.     int hours;
  19. public:
  20.     Employee2(int wage, int hours) {
  21.         this->wage = wage;
  22.         this->hours = hours;
  23.     };
  24.     virtual double countup() override {return hours * wage;};
  25. };
  26. int main(){
  27.     setlocale(LC_ALL, "Russian");
  28.  
  29.     Employee1 e1(500);
  30.     cout << e1.countup() << endl;
  31.     Employee2 e2(2, 10);
  32.     cout << e2.countup() << endl;
  33.    
  34. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement