Click on main.cpp to get source.

// File: C++Examples/Stacks/main.cpp 
//
// This is the C++ version of the C example
//
//    ../CExamples/OO_pgm_in_C/
//
// One would not normally write a stack in C++
// this way, but use the STL stack adaptor.
//
// The C++ version is distinguished from
// the C version in that the main program is
// not generic.  For that purpose, one could have a
// function
//
//    stack* make_stack();
//
// in array_stack.cpp that is loaded at link time.
// Vice-versa, the C version could store a pointer
// to the new_stack() in struct stack, so that
// both list_stacks and array_stacks can be used
// in main.
//
// Reference:
// http://www4.ncsu.edu/~kaltofen/bibliography/96/EKM96.pdf

#include <iostream>
#include "array_stack.h"

// can't use namespace std because conflict with "stack" name

int main(void)
// Test the stack 
{int i;
 stack& st = *(new array_stack());
// test: stack st = *(new array_stack());

 std::cout << st << std::endl;
 for (i=1; i < 6; i++)
     { std::cout <<  "Pushing " << i << std::endl;
       st.push(i);
       std::cout << st << std::endl;
     }
 
 for (i=0; i < 3; i++)
     { std::cout << "Popping " << st.pop() << std::endl;
       std::cout << st << std::endl;
     }
 return 0;
}