Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class DANE_OSOBOWE
- {
- protected:
- string imie;
- string nazwisko;
- unsigned wiek;
- public:
- DANE_OSOBOWE(string, string, unsigned);
- virtual void wypisz_dane() = 0;
- };
- class STUDENT : public DANE_OSOBOWE
- {
- double srednia;
- string kierunek;
- public:
- STUDENT(string, string, unsigned, double, string);
- void wypisz_dane();
- double suma_kontrolna();
- };
- class PRACOWNIK : public DANE_OSOBOWE
- {
- double wynagrodzenie;
- unsigned przepracowane_lata;
- public:
- PRACOWNIK(string, string, unsigned, double, unsigned);
- void wypisz_dane();
- double srednia();
- };
- DANE_OSOBOWE::DANE_OSOBOWE(string name, string scnd_name, unsigned age) : imie(name), nazwisko(scnd_name), wiek(age) {}
- STUDENT::STUDENT(string name, string scnd_name, unsigned age, double avrg, string topic) : DANE_OSOBOWE(name, scnd_name, age), srednia(avrg), kierunek(topic) {}
- void STUDENT::wypisz_dane()
- {
- cout << imie << ' ' << nazwisko << " (student), wiek: " << wiek << " lata, suma kontrolna = " << suma_kontrolna() << endl;
- }
- double STUDENT::suma_kontrolna()
- {
- return srednia / wiek;
- }
- PRACOWNIK::PRACOWNIK(string name, string scnd_name, unsigned age, double sallary, unsigned lata) : DANE_OSOBOWE(name, scnd_name, age), wynagrodzenie(sallary), przepracowane_lata(lata) {}
- void PRACOWNIK::wypisz_dane()
- {
- cout << imie << ' ' << nazwisko << " (pracownik), wiek: " << wiek << " lata, srednie zarobki = " << srednia() << endl;
- }
- double PRACOWNIK::srednia()
- {
- return przepracowane_lata * 12 * wynagrodzenie / wiek;
- }
- int main()
- {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment