#include struct IntStack { bool (*push)(int data, IntStack&); bool (*pop)(int &data, IntStack&); int top; int data[1000]; }; bool push(int value, IntStack &stack) { if (stack.top >= 1000) return false; else { stack.data[stack.top++] = value; return true; } } bool pop(int &value, IntStack &stack) { if (stack.top <= 0) return false; else { value = stack.data[--stack.top]; return true; } } void main() { int i, value; IntStack theStack = {push, pop, 0}; for (i=0; i<10; i++) assert(theStack.push(i, theStack)); for (i=0; i<10; i++) { assert(theStack.pop(value, theStack)); assert(value == 9-i); } }