Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. class Wykladowca {
  7.    public:
  8.  
  9.     virtual void mow() = 0;
  10.  
  11. };
  12.  
  13. class Bandurski :public Wykladowca
  14. {
  15.  
  16.     string tekst;
  17.  
  18. public:
  19.     Bandurski(string m = "Podej Harnasia")
  20.     {
  21.          tekst=m;
  22.     }
  23.     virtual void mow()
  24.     {
  25.         cout << tekst << endl;
  26.     }
  27.  
  28. };
  29.  
  30.  
  31. class Stankowski :public Wykladowca
  32. {
  33.  
  34.     string tekst;
  35.  
  36. public:
  37.     Stankowski(string m = "Wyjebalo switch")
  38.     {
  39.         tekst = m;
  40.     }
  41.     virtual void mow()
  42.     {
  43.         cout << tekst << endl;
  44.     }
  45.  
  46. };
  47.  
  48.  
  49.  
  50. void reakcja(Wykladowca *wsk)
  51. {
  52.     wsk->mow();
  53.  
  54. }
  55.  
  56. int main()
  57. {
  58.     Bandurski bandyta;
  59.     Stankowski stanek;
  60.     Wykladowca *w;
  61.     w = &stanek; //ustawienie wskaznika
  62.     reakcja(w);
  63.     system("pause");
  64.     return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement