// tStack2.cpp (C) 2004 adolfo@di-mare.com /* resultado Prueba el contenedor Stack. */ class Stack_int { public: Stack_int() { _top = 0; return; } void Push(int d) { _vec[_top] = d; _top++; return; } int Pop() { _top--; return _vec[_top]; } int Top() { return _vec[_top-1]; } int Count() { return _top; } private: enum { Capacity = 132 }; int _top; // tope de la pila int _vec[Capacity]; // vector para la pila }; // Stack_int int main() { Stack_int S; int d = -1; S.Push(1); // 1 S.Push(2); // 1 2 S.Push(3); // 1 2 3 S.Push(4); // 1 2 3 4 S.Push(5); // 1 2 3 4 5 d = S.Pop(); // 1 2 3 4 [5] d = S.Count(); // 4 S.Push(6); // 1 2 3 4 6 d = S.Count(); // 5 S.Push(7); // 1 2 3 4 6 7 d = S.Count(); // 6 d = S.Pop(); // 1 2 3 4 6 [7] d = S.Count(); // 5 return 0; } // main() // EOF: tStack2.cpp