Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class pracownik //Klasa pracownik
- {
- string imie, nazwisko;
- public: //Klauzula public
- pracownik(string i = "Jan", string n = "Kowalski") //Konstruktor klasy pracownik
- {
- imie = i;
- nazwisko = n;
- }
- void wyswietl() //Metoda wypisująca imie i nazwisko pracownika
- {
- cout << "Imie i nazwisko: " << imie << " " << nazwisko << endl;
- }
- };
- class menager : public pracownik //Klasa menager dziedziczaca z klasy pracownik
- {
- float pensja;
- public:
- menager(string i="Jan", string n="Kowalski", float p=3000):pracownik(i, n) //Konstruktor z klasy pracownik wykorzystay w klasie menager
- {
- pensja = p;
- }
- void wyswietl()
- {
- pracownik::wyswietl(); //Wywolanie metody z klasy pracownik
- cout << "Pensja wynosi: " << pensja << endl;
- }
- };
- class szef : public menager
- {
- float premia;
- public:
- szef(string i = "Jan", string n = "Kowalski", float pen = 3000, float prem = 200) :menager(i, n, pen)
- {
- premia = prem;
- }
- void wyswietl()
- {
- menager::wyswietl(); //Wywolanie metody z klasy menager
- cout << "Premia wynosi: " << premia << endl;
- }
- };
- int main()
- {
- szef m;
- m.wyswietl();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement