// @topic T060870 Stack of integers v3
// @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;
int x, y, z = 1;
st = st;
x = (y = z);
(x + y) + z;
//Stack st2;
Stack st3;
st3 = st2 = st;
st3.operator=( st2.operator=(st) ); // st3 = 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");
}