Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. class stack
  2. {
  3. int top;
  4. public:
  5. int arr[500];
  6. stack()
  7. {
  8. top=-1;
  9. }
  10.  
  11. void push(int);
  12.  
  13. };
  14.  
  15. void stack::push(int item)
  16. {
  17.  
  18.  
  19. arr[top++]=item; //problem here
  20. cout<<"n"<<item<<"pushed in stack";
  21. cout<<"n top value is"<<top;
  22. }
  23.  
  24.  
  25. int main()
  26. {
  27. stack s;
  28. s.push(12);
  29. s.push(19);
  30. s.push(31);
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement