Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Zwierze
- {
- private:
- string gatunek;
- string ruch;
- string glos;
- public:
- virtual void daj_glos() = 0;
- virtual void pole() = 0;
- };
- class Pies : public Zwierze
- {
- float a;
- public:
- Pies(float x)
- {
- a=x;
- }
- void daj_glos()
- {
- cout << "Hau hau!" << endl;
- }
- void pole()
- {
- cout << "Pole psa to: " << 4*a << endl;
- }
- };
- class Kot : public Zwierze
- {
- float a;
- public:
- Kot(float x)
- {
- a=x;
- }
- void daj_glos()
- {
- cout << "Miau miau!" << endl;
- }
- void pole()
- {
- cout << "Pole kota to: " << a*a << endl;
- }
- };
- int main()
- {
- Pies burek(2);
- Kot filek(2);
- Zwierze *wsk;
- wsk = &burek;
- wsk -> daj_glos();
- wsk -> pole();
- wsk = &filek;
- wsk -> daj_glos();
- wsk -> pole();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement