Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // obiektowka-polimorfizm.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream>
- #include <vector>
- using namespace std;
- Zwierze* tab[10];
- class Zwierze {
- public:
- string rasa;
- float wzrost;
- int* wskaz;
- virtual void sound() {
- cout << "gib sound pls" << endl;
- }
- void* wyswietl()
- {
- }
- };
- class Cat:public Zwierze {
- public:
- Cat() {
- rasa = 'Kot';
- cin >> wzrost;
- }
- void sound()
- {
- cout << "Miau" << endl;
- }
- };
- class Dog :public Zwierze {
- public:
- Dog()
- {
- rasa = 'Pies';
- cin >> wzrost;
- sound();
- }
- void sound()
- {
- cout << "Hauhau" << endl;
- }
- };
- class Horse :public Zwierze {
- public:
- Horse()
- {
- rasa = 'Kon';
- cin >> wzrost;
- }
- void sound()
- {
- cout << "prrrrrrrrt" << endl;
- }
- };
- int main()
- {
- Zwierze* wsk;
- int wybor;
- cin >> wybor;
- for (;;)
- {
- if (wybor == 1)
- {
- wsk = new Dog();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement