All pastes #498606 Raw Edit

Something

public text v1 · immutable
·published 2007-05-20 15:40 UTC
rendered paste body
Stack.h file


const int maxStack = 16;

class IStack
{
public:
    IStack () :_top (0) {}
    void Push (int i);
    int  Pop ();
private:
    int _arr [maxStack];
    int _top;
};

============================================================
fillstack.cpp file


#include "stack.h"
#include <cassert>
#include <iostream>
using std::cout;
using std::endl;
NDEBUG=1
//compile with NDEBUG=1 to get rid of assertions

void IStack::Push (int i)
{
#   assert (_top < maxStack);
    _arr [_top] = i;
    ++_top;
}

int IStack::Pop ()
{
#   assert (_top > 0);
    --_top;
    return _arr [_top];
}