// @topic T060770 Stack of integers v2 // @brief main entry point #include <cstdlib> #include <iostream> #include "Stack.h" // Demonstrates passing the original // stack object as a parameter without // copying -- by reference. // The const keyword restricts the // parameter as read-only object. void use_stack(Stack const& st) { int x = st.top(); } void doit() { // construct stack with capacity of 20 elements Stack st(20); // Make a copy of the stack. Stack class copy // constructor is invoked: Stack st2 = st; // Use st2 elswhere in the program. // The object is passed to the function // by reference, no copy is made: use_stack(st2); } int main() { doit(); system("pause"); }