stack4 - return -1; } return data[size-1]; } void...

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

View Full Document Right Arrow Icon
Separating Interface and Implementation #define STACK_MAX 100 class Stack { private: int data[STACK_MAX]; int size; public: Stack() { size = 0; } // Constructor ~Stack() { } // Destructor int Top(); void Push(int d); void Pop(); }; int Stack::Top() { if (size == 0) { fprintf(stderr, "Error: stack empty\n");
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 -1; } return data[size-1]; } void Stack::Push(int d) { if (size < STACK_MAX) data[size++] = d; else fprintf(stderr, "Error: stack full\n"); } void Stack::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

stack4 - return -1; } return data[size-1]; } void...

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