arsovski

Untitled

Mar 25th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include"Stack.h"
  2. stack::stack() {
  3. top = -1;
  4. arr[NUM]=NULL;
  5. }
  6. void stack::setTop(int top) {
  7. this->top = top;
  8. }
  9. int stack::getTop() const {
  10. return this->top;
  11. }
  12. int stack::checkTop() const {
  13. return arr[getTop()];
  14. }
  15. bool stack::empty() const {
  16. return (top == 0);
  17. }
  18. void stack::push(int element) {
  19. setTop(getTop()+1);
  20. arr[getTop()] = element;
  21. }
Add Comment
Please, Sign In to add comment