9
edits
Changes
no edit summary
'''isempty''' - this function takes no arguments and returns a bool. If the stack is empty, return true, otherwise return false<br><br>
'''push '''- this function takes an instance of the unknown data type T as its only parameter and returns nothing. It will put the data onto the stack.<br><br>
pop - this function takes no arguments and returns an instance of the unknown data type T. It will remove and return the last piece of data that was added. If the stack isempty when this function is called, the function should throw the string "empty stack" as an exception.<br><br>
Sample main:
<source lang="cpp">
int main(void){
Stack<int> IS; //integer stack
catch(char* s){ cout << s << endl;} //empty stack
}
</source>
Hint: think of push as inserting to front of linked list and pop as removing from front of linked list