Advertisement
Guest User

cviko8

a guest
Apr 1st, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. // cvicenie8.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "stdlib.h"
  6. #include "stdio.h"
  7. #include <iostream>
  8.  
  9. using namespace std;
  10.  
  11. template<class T> class LIFO
  12. {
  13. T*p;
  14. const int max;
  15. int aktualna;
  16.  
  17. public:
  18. LIFO(const int max)
  19. {
  20.  
  21. this->aktualna = 0;
  22. this->p = new T[max];
  23. }
  24.  
  25. ~LIFO()
  26. {
  27. delete[] p;
  28. }
  29.  
  30. void push(T p)
  31. {
  32. if(cout>=max)
  33. throw new Exception("Nie je mozne pridat prvok do plneho zasobniku");
  34. p[cout++]= p;
  35.  
  36.  
  37. }
  38.  
  39. void tisk()
  40. {
  41. for (int i = 0;i<cout; i++)
  42. {
  43. cout << p[i];
  44. }
  45. }
  46.  
  47. T pop()
  48. {
  49. if (cout <= 0)
  50. throw new Exception("Nie je mozne odobrat prvok z prazdneho zasobniku");
  51. return p[count--];
  52. }
  53.  
  54.  
  55. };
  56.  
  57.  
  58.  
  59. int _tmain(int argc, _TCHAR* argv[])
  60. {
  61.  
  62. /*while(1)
  63. {
  64.  
  65. }*/
  66.  
  67. system("pause");
  68. return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement