Adding a member function - Exercise |
||
const int max_len = 40; struct ch_stack { //data representation char s[max_len]; int top; enum { EMPTY = -1, FULL = max_len - 1 }; //operations represented as member functions void reset() { top = EMPTY; } void push(char c) { assert(top != FULL); top++; s[top] = c; } char pop() { assert(top!= EMPTY); return s[top--]; } char top_of() { assert(top!= EMPTY); return s[top]; } bool empty() { return (top == EMPTY); } bool full() { return (top == FULL); } }; |
||
|
Paste the source code for the member function below and click the Submit
button when you are ready to submit this exercise.
|
||