different between push and pop.

Can anybody explain why in this tutorial the program for push and pop is same?
I didnt know what is different about the pop and push.
There no different in that program.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  // stack::push/pop
#include <iostream>       // std::cout
#include <stack>          // std::stack

int main ()
{
  std::stack<int> mystack;

  for (int i=0; i<5; ++i) mystack.push(i);

  std::cout << "Popping out elements...";
  while (!mystack.empty())
  {
     std::cout << ' ' << mystack.top();
     mystack.pop();
  }
  std::cout << '\n';

  return 0;
}

They are very different, even in that example. I presume that you took that example program from the reference documentation pages?

Read the description of each function carefully.
But in this reference the program that give by writer there no differences.
I didnt understand what the different push and pop.
You see no difference in these?
1
2
push( i )
pop()


You see no difference in insertion and removal?
push puts an element in a vector..
pop removes the last element from a vector..

They are not the same.
Topic archived. No new replies allowed.