Advertisement
Guest User

x

a guest
May 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Zwierze
  6. {
  7. private:
  8. string gatunek;
  9. string ruch;
  10. string glos;
  11.  
  12. public:
  13. virtual void daj_glos() = 0;
  14. virtual void pole() = 0;
  15. };
  16.  
  17. class Pies : public Zwierze
  18. {
  19. float a;
  20. public:
  21. Pies(float x)
  22. {
  23. a=x;
  24. }
  25. void daj_glos()
  26. {
  27. cout << "Hau hau!" << endl;
  28. }
  29. void pole()
  30. {
  31. cout << "Pole psa to: " << 4*a << endl;
  32. }
  33. };
  34.  
  35. class Kot : public Zwierze
  36. {
  37. float a;
  38. public:
  39. Kot(float x)
  40. {
  41. a=x;
  42. }
  43. void daj_glos()
  44. {
  45. cout << "Miau miau!" << endl;
  46. }
  47. void pole()
  48. {
  49. cout << "Pole kota to: " << a*a << endl;
  50. }
  51.  
  52. };
  53.  
  54. int main()
  55. {
  56. Pies burek(2);
  57. Kot filek(2);
  58.  
  59. Zwierze *wsk;
  60.  
  61. wsk = &burek;
  62. wsk -> daj_glos();
  63. wsk -> pole();
  64.  
  65. wsk = &filek;
  66. wsk -> daj_glos();
  67. wsk -> pole();
  68.  
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement