fork download
  1. #include"CStack.hpp"
  2.  
  3. namespace bai25{
  4. CStack::CStack()
  5. {
  6. counter = 0;
  7. try{
  8. stack = new int32_t[MAX];
  9. }
  10. catch(bad_alloc&){
  11. cout<<"ko the tao stack"<<endl;
  12. }
  13. }
  14.  
  15. CStack::CStack(int32_t data)
  16. {
  17. try{
  18. stack = new int32_t[MAX];
  19. }
  20. catch(bad_alloc&)
  21. {
  22. cout<<"ko the tao stack"<<endl;
  23. }
  24. counter = 1;
  25. stack[0] = data;
  26. }
  27.  
  28. bool CStack::IsEmpty()
  29. {
  30. if(!this->counter)
  31. {
  32. return true;
  33. }
  34.  
  35. return false;
  36. }
  37.  
  38. bool CStack::IsFull()
  39. {
  40. if(this->counter == MAX - 1)
  41. {
  42. return true;
  43. }
  44.  
  45. return false;
  46. }
  47.  
  48. CStack::~CStack()
  49. {
  50. delete[] stack;
  51. }
  52.  
  53. void CStack::Push(const int32_t data)
  54. {
  55. this->stack[this->counter] = data;
  56. (this->counter)++;
  57. }
  58.  
  59. void CStack::Pop()
  60. {
  61. int32_t data = this->stack[this->counter];
  62. cout<<data<<endl;
  63. if(this->counter)
  64. {
  65. (this->counter)--;
  66. }
  67. }
  68.  
  69. }
  70.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:21: fatal error: CStack.hpp: No such file or directory
 #include"CStack.hpp"
                     ^
compilation terminated.
stdout
Standard output is empty