#include using namespace std; class Stack { private: int* a; int top; int capacity; void resize() { int* tmp; tmp = new int[capacity * 2]; for(int i = 0; i < capacity; i++) { tmp[i] = a[i]; } delete []a; a = tmp; capacity *= 2; } public: Stack() { capacity = 10; a = new int[capacity]; top = - 1; } bool isEmpty() { return top == - 1; } void push(int x) { if(isFull()) { resize(); } a[++top] = x; } int pop() { if(isEmpty()) { cout << "Опит за поглеждане в празен стек!" << endl; return 0; } return a[top--]; } bool isFull() { return top == capacity - 1; } int peek() { if(isEmpty()) { return 0; } return a[top]; } Stack(Stack const& s) { a = new int[s.capacity]; for(int i = 0; i <= s.top; i++) { a[i] = s.a[i]; } top = s.top; capacity = s.capacity; } Stack& operator= (Stack const& s) { if(a != NULL) { delete []a; } a = new int[s.capacity]; for(int i = 0; i <= s.top; i++) { a[i] = s.a[i]; } top = s.top; capacity = s.capacity; return *this; } ~Stack() { delete []a; } }; int main(){ Stack A; A.push(4); A.pop(); A.isEmpty(); return 0; }