#include <iostream>

class Stack
{
    int* m_head;
    int m_size;
    int m_index;
public:
    Stack(int size) : m_size{ size }, m_index{ 0 } {
        m_head = new int[size];
    }
    ~Stack() {
        delete[] m_head;
    }
    bool push (int x)
    {
        if (m_index < m_size)
        {
            m_head[m_index++] = x;
            return true;
        }
        std::cout << "the stack is full" << std::endl;
        return false;
    }
};
int main()
{
    int n = 5;
    Stack stack{n};
    for (int i = 0; i < n; i++) {
        if (!stack.push(i)) return;
    }
}
