Advertisement
Guest User

Untitled

a guest
Jan 18th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. // obiektowka-polimorfizm.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <vector>
  7. using namespace std;
  8.  
  9.  
  10. Zwierze* tab[10];
  11.  
  12. class Zwierze {
  13.  
  14.  
  15. public:
  16. string rasa;
  17. float wzrost;
  18. int* wskaz;
  19. virtual void sound() {
  20. cout << "gib sound pls" << endl;
  21. }
  22.  
  23. void* wyswietl()
  24. {
  25.  
  26. }
  27.  
  28.  
  29. };
  30.  
  31. class Cat:public Zwierze {
  32.  
  33. public:
  34. Cat() {
  35. rasa = 'Kot';
  36. cin >> wzrost;
  37.  
  38.  
  39. }
  40. void sound()
  41. {
  42. cout << "Miau" << endl;
  43. }
  44. };
  45.  
  46.  
  47. class Dog :public Zwierze {
  48.  
  49. public:
  50. Dog()
  51. {
  52. rasa = 'Pies';
  53. cin >> wzrost;
  54. sound();
  55.  
  56.  
  57.  
  58.  
  59. }
  60. void sound()
  61. {
  62.  
  63. cout << "Hauhau" << endl;
  64. }
  65. };
  66.  
  67. class Horse :public Zwierze {
  68.  
  69. public:
  70. Horse()
  71. {
  72. rasa = 'Kon';
  73. cin >> wzrost;
  74. }
  75. void sound()
  76. {
  77. cout << "prrrrrrrrt" << endl;
  78. }
  79. };
  80.  
  81.  
  82.  
  83.  
  84.  
  85. int main()
  86. {
  87. Zwierze* wsk;
  88. int wybor;
  89. cin >> wybor;
  90. for (;;)
  91. {
  92.  
  93. if (wybor == 1)
  94. {
  95. wsk = new Dog();
  96.  
  97. }
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105. }
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement