// @topic T060970 Stack of integers v4 // @brief main entry point #include <cstdlib> #include <iostream> #include "Stack.h" // This function uses stack passed by reference. // No copying is taking place: void use_stack(Stack const& st) { std::cout << __FUNCTION__; std::cout << " Size of stack is " << st.size() << '\n'; } // This function creates and returns a stack object. // The object "moves" to the caller's scope, because // class Stack provides the move constructor Stack create_stack() { // construct stack with 5 elements: Stack st = Stack{ 10, 20, 30, 40, 50 }; st.push(10); st.push(20); return st; // the object "moves" to caller's scope } void doit() { Stack st = create_stack(); use_stack( st ); std::cout << "Size of stack is " << st.size() << '\n'; } int main() { doit(); system("pause"); }