fork download
  1. //stack.cpp - metody klasy stosu
  2. #include "stack.h"
  3. Stack::Stack() //tworzy pusty stos
  4. {
  5. top = 0;
  6. }
  7.  
  8. bool Stack::isempty() const
  9. {
  10. return top == 0;
  11. }
  12.  
  13. bool Stack::isfull() const
  14. {
  15. return top == MAX;
  16. }
  17.  
  18. bool Stack::push(const Item & item)
  19. {
  20. if (top < MAX)
  21. {
  22. items[top++] = item;
  23. return true;
  24. }
  25. else
  26. return false;
  27. }
  28.  
  29. bool Stack::pop(Item & item)
  30. {
  31. if (top > 0)
  32. {
  33. item = items[--top];
  34. return true;
  35. }
  36. else
  37. return false;
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:19: error: stack.h: No such file or directory
prog.cpp:3: error: ‘Stack’ has not been declared
prog.cpp:3: error: ISO C++ forbids declaration of ‘Stack’ with no type
prog.cpp: In function ‘int Stack()’:
prog.cpp:5: error: ‘top’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:8: error: ‘Stack’ is not a class or namespace
prog.cpp:8: error: non-member function ‘bool isempty()’ cannot have cv-qualifier
prog.cpp: In function ‘bool isempty()’:
prog.cpp:10: error: ‘top’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:13: error: ‘Stack’ is not a class or namespace
prog.cpp:13: error: non-member function ‘bool isfull()’ cannot have cv-qualifier
prog.cpp: In function ‘bool isfull()’:
prog.cpp:15: error: ‘top’ was not declared in this scope
prog.cpp:15: error: ‘MAX’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:18: error: ‘Stack’ is not a class or namespace
prog.cpp:18: error: expected ‘,’ or ‘...’ before ‘&’ token
prog.cpp:18: error: ISO C++ forbids declaration of ‘Item’ with no type
prog.cpp: In function ‘bool push(int)’:
prog.cpp:20: error: ‘top’ was not declared in this scope
prog.cpp:20: error: ‘MAX’ was not declared in this scope
prog.cpp:22: error: ‘items’ was not declared in this scope
prog.cpp:22: error: ‘item’ was not declared in this scope
prog.cpp: At global scope:
prog.cpp:29: error: ‘Stack’ is not a class or namespace
prog.cpp:29: error: ‘Item’ was not declared in this scope
prog.cpp:29: error: ‘item’ was not declared in this scope
prog.cpp:30: error: expected ‘,’ or ‘;’ before ‘{’ token
stdout
Standard output is empty