int main() { long storage[100]; AbstractStack* stack = new (storage) Stack<EthernetProtocol>(); stack->upgrade(IPv4); stack->upgrade(IPv6); }
void stackTest() { cout << "Stack test:" << endl; AbstractStack<int>* stack = new StackByArray<int>; stackIsEmpty(stack); const int iter = 12; for (int i = 0; i < iter; ++i) { cout << "Enter value "; int val; cin >> val; cout << " push " << val << endl; stack->push(val); } stackIsEmpty(stack); for (int i = 0; i < iter; ++i) { cout << "Top element: " << stack->top() << endl; cout << "Pop element: " << stack->pop() << endl; } stackIsEmpty(stack); delete stack; }
void printStack(AbstractStack<int>& stack) { while (!stack.empty()) cout << stack.pop() << endl; }