Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // cvicenie8.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include "stdlib.h"
- #include "stdio.h"
- #include <iostream>
- using namespace std;
- template<class T> class LIFO
- {
- T*p;
- const int max;
- int aktualna;
- public:
- LIFO(const int max)
- {
- this->aktualna = 0;
- this->p = new T[max];
- }
- ~LIFO()
- {
- delete[] p;
- }
- void push(T p)
- {
- if(cout>=max)
- throw new Exception("Nie je mozne pridat prvok do plneho zasobniku");
- p[cout++]= p;
- }
- void tisk()
- {
- for (int i = 0;i<cout; i++)
- {
- cout << p[i];
- }
- }
- T pop()
- {
- if (cout <= 0)
- throw new Exception("Nie je mozne odobrat prvok z prazdneho zasobniku");
- return p[count--];
- }
- };
- int _tmain(int argc, _TCHAR* argv[])
- {
- /*while(1)
- {
- }*/
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement