Advertisement
Guest User

Zadanko 5

a guest
Apr 8th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class pracownik                                                                     //Klasa pracownik
  7. {
  8.     string imie, nazwisko;                                                         
  9. public:                                                                             //Klauzula public
  10.     pracownik(string i = "Jan", string n = "Kowalski")                              //Konstruktor klasy pracownik
  11.     {
  12.         imie = i;
  13.         nazwisko = n;
  14.     }
  15.     void wyswietl()                                                                 //Metoda wypisująca imie i nazwisko pracownika
  16.     {
  17.         cout << "Imie i nazwisko: " << imie << " " << nazwisko << endl;
  18.     }
  19. };
  20.  
  21. class menager : public pracownik                                                    //Klasa menager dziedziczaca z klasy pracownik
  22. {
  23.     float pensja;
  24. public:
  25.     menager(string i="Jan", string n="Kowalski", float p=3000):pracownik(i, n)      //Konstruktor z klasy pracownik wykorzystay w klasie menager
  26.     {
  27.         pensja = p;
  28.     }
  29.    
  30.     void wyswietl()
  31.     {
  32.         pracownik::wyswietl();                                                      //Wywolanie metody z klasy pracownik
  33.         cout << "Pensja wynosi: " << pensja << endl;
  34.     }
  35.  
  36. };
  37.  
  38. class szef : public menager
  39. {
  40.     float premia;
  41. public:
  42.     szef(string i = "Jan", string n = "Kowalski", float pen = 3000, float prem = 200) :menager(i, n, pen)
  43.     {
  44.         premia = prem;
  45.     }
  46.     void wyswietl()
  47.     {
  48.         menager::wyswietl();                                                        //Wywolanie metody z klasy menager
  49.         cout << "Premia wynosi: " << premia << endl;
  50.     }
  51. };
  52.  
  53.  
  54.  
  55.  
  56. int main()
  57. {
  58.     szef m;
  59.     m.wyswietl();
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement