// @topic W09-1-010 C++ std::stack example
// @brief main driver program using std::stack class

#include <iostream>
#include <cstdlib>
#include <stack>

void display_array( int * xarray, int array_size )
{
    // display the content of the array:
    for ( int idx = 0; idx < array_size; ++idx ) {
        std::cout << " " << xarray[ idx ];
    }
    std::cout << "\n";
}//display_array

int main()
{
    std::stack<int> st; // what is a stack?
    const int ARRAY_SIZE = 5;
    int myarray[ ARRAY_SIZE ] = { 11, 22, 33, 44, 55 };
    display_array( myarray, ARRAY_SIZE );

    for ( int idx = 0; idx < ARRAY_SIZE; ++idx ) {
        st.push( myarray[ idx ] );
    }
    // at this point the stack is populated with
    // bottom -- 11 22 33 44 55 -- top
    for ( int idx = 0; idx < st.size(); ++idx ) {
        myarray[ idx ] = st.top();
        st.pop(); // removes the element from the top of the stack
    }
    display_array( myarray, ARRAY_SIZE );
    system("pause");
    return 0;
}
/*
    typedef int units_of_measurement;
    units_of_measurement unit;
    int unit;
    typedef std::stack<int> Mystack;
    Mystack st;
*/
