#pragma once
#define STACKSIZE 10
#include <iostream>
using namespace std;

class Stack
{
public:
	Stack(){ sp = -1; underflow = false; overflow = false; }
	void push(int);
	int pop(void);
	bool getUnderflow(void) { return underflow; }
private:
	int sp;
	int list[STACKSIZE];
	bool isFull(void);
	bool isEmpty(void);
	bool underflow;
	bool overflow;
};

#include "stack.h"
bool Stack::isFull(void)
{
	if (sp >= STACKSIZE - 1)
		return true;

	else
		return false;
}

bool Stack::isEmpty(void)
{
	if (sp<0)
		return true;
	else
		return false;
}

void Stack::push(int x)
{
	if (!isFull())
	{
		sp++;
		list[sp] = x;
		overflow = false;
	}
	else
		overflow = true;
}

int Stack::pop(void)
{
	if (!isEmpty())
	{
		int temp = list[sp];
		sp--;
		underflow = false;
		return temp;
	}
	else
		underflow = true;
	return -1;
}

#include "stack.h"
#include <iostream>
using namespace std;



int main(void)
{
	Stack myStack;
	for (int i = 0; i< STACKSIZE + 1; i++)
	{
		cout << "Pushing " << i << endl;
		myStack.push(i);
	}
	cout << endl;
	for (int i = 0; i< STACKSIZE + 1; i++)
	{
		int data = myStack.pop();
		if (myStack.getUnderflow())
			cout << "Stack empty" << endl;
		else
			cout << "Popping " << data << endl;
	}

	return 0;
}