Advertisement
Guest User

Untitled

a guest
May 31st, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Opcja
  6. {
  7. public:
  8. virtual void wybierz()
  9. {
  10. cout<<"?";
  11. }
  12. char k;
  13. };
  14.  
  15. class Pomoc: public Opcja
  16. {
  17. public:
  18. virtual void wybierz()
  19. {
  20. cout<<"Pomoc";
  21. }
  22. };
  23.  
  24. class Autor: public Opcja
  25. {
  26. public:
  27. virtual void wybierz()
  28. {
  29. cout<<"Autor";
  30. }
  31. };
  32.  
  33.  
  34. int main()
  35. {
  36. Opcja *w[2];
  37. char k;
  38. cin>>k;
  39. w[0]=new Autor;
  40. w[0]->k='a';
  41. w[1]=new Pomoc;
  42. w[1]->k='p';
  43. for(int i=0; i<2; i++)
  44. {
  45. if(k==w[i]->k) w[i]->wybierz();
  46.  
  47. }
  48. for (int i=0; i<2; i++)
  49. {
  50. delete w[i];
  51. }
  52.  
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement