#include <stdio.h>

template <class T, int cap>
class Stack {
    T data[cap];
    int len;
public:
    Stack() : len(0) {}
    bool Push(const T& d);
    bool Pop(T& d);
    bool Empty() const { return len == 0; }
};

template<class T, int cap>
bool Stack<T, cap>::Push(const T& d)
{
    if (len < cap) {
        data[len] = d;
        len++;
        return true;
    } else
        return false;
}

template<class T, int cap>
bool Stack<T, cap>::Pop(T& d)
{
    if (len > 0) {
        len--;
        d = data[len];
        return true;
    } else
        return false;
}

int main()
{
    int i;
    bool ok = true;
    Stack<int, 4> s;

    for (i = 1; i <= 6; i++) {
        ok = s.Push(i);
        printf("%d", ok);
    }
    printf("\n");

    while ((ok = s.Pop(i)))
        printf("%d ", i);
    printf("\n");

    Stack<int, 4> small;
    Stack<int, 8> big;
    printf("%ld %ld\n", sizeof(small), sizeof(big));

    // big = small;
    // const int n = 4; Stack<int, n> t;

    return 0;
}
