#include //oproti 3StackCPP je to 1 soubor #include #include class stack { private: int *stack_ptr; int max_len, top_ptr; public: stack() { stack_ptr = new int [100]; //constructor max_len = 99; top_ptr = -1; } ~stack() {delete [] stack_ptr;}; //destructor void push (int number) { if (top_ptr == max_len) cout << "error stack is full\n"; else stack_ptr[++top_ptr] = number; } int pop() { if (top_ptr == -1) { cout << "error stack is empty\n"; return 0;} else return (stack_ptr[top_ptr--]); } int top() {return (stack_ptr[top_ptr]);} int empty() {return (top_ptr == -1);} }; void main() { int t1, t2, t3; stack stk; //instance creation stk.push(25); stk.push(120); t1 = stk.top(); t2 = stk.pop(); t3 = stk.pop(); cout << t1 << " " << t2 << " " << t3 << endl; getch(); }