#ifndef stack_h #define stack_h #include "complex2.h" class StackIterator; class Stack { friend class StackIterator; int top; Complex *elems; public: Stack(int size = 50) { top = 0; elems = new Complex[size]; } ~Stack() { delete elems; } void push(Complex& i) { elems[top++]=i; } Complex pop() { return elems[--top]; } int empty() { return top == 0; } }; class StackIterator { int current; Stack* st; public: StackIterator(Stack* s) { st = s; current = 0; } int end() { return st->top == current; } Complex next() { return st->elems[current++]; } }; #endif