stack2 - } return data[size-1]; } void Push(int d) { if...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Stack Implementation in C++ #define STACK_MAX 100 class Stack { private: int data[STACK_MAX]; int size; public: Stack() { // Constructor size = 0; } ~Stack() { } // Destructor int Top() { if (size == 0) { fprintf(stderr, "Error: stack empty\n"); return -1;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } return data[size-1]; } void Push(int d) { if (size < STACK_MAX) data[size++] = d; else fprintf(stderr, "Error: stack full\n"); } void Pop() { if (size == 0) fprintf(stderr, "Error: stack empty\n"); else size--; } };...
View Full Document

This note was uploaded on 12/14/2011 for the course EECS 6.837 taught by Professor Durand during the Fall '03 term at MIT.

Page1 / 2

stack2 - } return data[size-1]; } void Push(int d) { if...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online