// @topic T060570 Stack of integers // @brief main entry point #include <cstdlib> #include <iostream> #include "Stack.h" int main() { int x = 10; int y = 20; Stack st(20); // Stack can preserve the values of the variables: st.push( x ); st.push( y ); // Modify and use values: x = 5555; y = 8888; // Get previous values from the stack. // Be careful -- restore values in the opposite order: y = st.top(); st.pop(); x = st.top(); st.pop(); // More stack functionality: st.push( 123 ); st.push( 456 ); std::cout << st.top() << '\n'; // prints 456 st.pop(); // remove value from the stack std::cout << st.top() << '\n'; // prints 123 // Replace value directly on the top of the stack: st.top() = 999; std::cout << st.top() << '\n'; // prints 999 std::cout << st.size() << '\n'; // prints stack size system("pause"); }