fork download
  1.  
  2. #include<iostream>
  3. #include<vector>
  4. #include<vector>
  5. using namespace std;
  6.  
  7. class stackx{
  8. private:
  9. int top;
  10. vector<double> stackVect;
  11. int maxSize;
  12.  
  13. public:
  14. stackx(int s): maxSize(s),top(-1){
  15. stackVect.reserve(maxSize);
  16. }
  17.  
  18. void push(double a){
  19. stackVect[++top]=a;
  20. }
  21.  
  22. double pop(){
  23. return stackVect[top--];
  24. }
  25.  
  26. double peek(){
  27. return stackVect[top];
  28. }
  29.  
  30. bool isEmpty(){
  31. return (top==-1);
  32. }
  33.  
  34. bool isFull(){
  35. return (top == maxSize-1);
  36. }
  37.  
  38. };
  39.  
  40.  
  41. int main(){
  42.  
  43. stackx stackvect(6);
  44. stackvect.push(20);
  45. stackvect.push(22);
  46. stackvect.push(13);
  47. stackvect.push(69);
  48. stackvect.push(123);
  49.  
  50. while(!stackvect.isEmpty()){
  51. double value = stackvect.pop();
  52. cout<<value<<" ";
  53. }
  54. cout<<endl;
  55. return 0;
  56. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
123 69 13 22 20