// tStack4.cpp (C) 2004 adolfo@di-mare.com /* resultado Prueba el contenedor Stack. */ #ifndef Tdef_h #include "Tdef.h" #endif // Tdef_h class Stack_T { public: Stack_T() { m_top = 0; return; } void Push(T d) { m_vec[m_top] = d; m_top++; return; } T Pop() { m_top--; return m_vec[m_top]; } T Top() { return m_vec[m_top-1]; } int Count() { return m_top; } private: enum { Capacity = 132 }; int m_top; // tope de la pila T m_vec[Capacity]; // vector para la pila }; // Stack_T int main() { Stack_T 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: tStack4.cpp