fork download
  1. #include "StdAfx.h"
  2. #include "Stos.h"
  3. #include "string"
  4. Stos::Stos(void)
  5. {
  6.  
  7. last = 0;
  8. size = 20;
  9. Numbers = 0;
  10.  
  11. tab = new int[size];
  12.  
  13. if(tab == NULL)
  14. {
  15. throw "Error";
  16. }
  17.  
  18.  
  19. }
  20.  
  21. Stos::Stos(long lSize)
  22. {
  23.  
  24. last = 0;
  25. size = lSize;
  26. Numbers = 0;
  27.  
  28. tab = new int[size];
  29.  
  30. if(tab == NULL)
  31. {
  32. throw "Error";
  33. }
  34. }
  35.  
  36. void Stos::Push(int elem)
  37. {
  38. if(last < size)
  39. {
  40. tab[last ++] = elem;
  41. Numbers ++;
  42. }
  43. else
  44. {
  45. GrowStack();
  46. }
  47. }
  48.  
  49. int Stos::Pop()
  50. {
  51. if(last >= 0)
  52. {
  53. Numbers --;
  54. return tab[--last];
  55. }
  56. }
  57.  
  58.  
  59. unsigned Stos::Stack0()
  60. {
  61. if(last >= 0)
  62. {
  63.  
  64. return 1;
  65. }
  66. else return 0;
  67. }
  68.  
  69. const int& Stos::Top()
  70. {
  71. return tab[last - 1];
  72. }
  73.  
  74. void Stos::GrowStack()
  75. {
  76. int *newTab = new int[size + 10];
  77.  
  78. for(int i=0; i < size; i++)
  79. newTab[i] = tab[i];
  80. delete []tab;
  81.  
  82. tab = newTab;
  83.  
  84. size += 10;
  85. }
  86.  
  87. long Stos::GetNumbers()
  88. {
  89. return Numbers;
  90. }
  91.  
  92. Stos::~Stos(void)
  93. {
  94. delete []tab;
  95. }
  96.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:20: fatal error: StdAfx.h: No such file or directory
 #include "StdAfx.h"
                    ^
compilation terminated.
stdout
Standard output is empty