Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int ilosc_ludzi;
- cout << "Podaj dlugosc kolejki: ";
- cin >> ilosc_ludzi;
- cout << "\n";
- Czlowiek** ludzie = new (nothrow) Czlowiek*[ilosc_ludzi];
- for (int i = 0; i < ilosc_ludzi; i++)
- {
- if (i % 2)
- {
- ludzie[i] = new (nothrow) Pracownik(i);
- }
- else
- {
- ludzie[i] = new (nothrow) Student(i);
- }
- }
- for (int n = 0; n < ilosc_ludzi; n++)
- {
- (*ludzie[n]).przedstawSie();
- (*ludzie[n]).pij();
- }
- };
- class Czlowiek
- {
- protected:
- string imie;
- string nazwisko;
- public:
- virtual void pij() = 0;
- virtual void przedstawSie()
- {
- cout << "Jestem " << imie << " " << nazwisko <<"\n";
- }
- };
- class Student :public Czlowiek
- {
- private:
- int nr_indeksu;
- public:
- void pij()
- {
- for (int i = 0; i < 3; i++) {
- cout << imie << " " << "PIJE JAK STUDENT" << "\n";
- }
- }
- void przedstawSie()
- {
- cout << "Jestem " << imie << " " << nazwisko << " " << nr_indeksu << "\n";
- }
- Student(int par)
- {
- this->imie = "Student " + par;
- this->nazwisko = "Studencki " + par;
- this->nr_indeksu = 136690 + par;
- }
- };
- class Pracownik :public Czlowiek
- {
- public:
- void pij()
- {
- cout << "PIJE JAK PRACOWNIK" << "\n";
- }
- Pracownik(int par)
- {
- this->imie = "Pracownik " + par;
- this->nazwisko = "Pracownicki " + par;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement