-
push n pop
can someone briefly explain push and pop with a small simpe program writen in c++ here? if possible, ill be thankful! please dont direct me to links etc, i want something on which we can discuss here!! thanks
what's my knowledge about pop / push? all I understood is that pop is used to remove and push is used to add
-
You are probably talking about a stack. Perhaps googling the subject of "stack" would help?
--
Mats
-
-
Run this code and see if if helps.
Code:
#include <iostream>
#include <stack>
int main()
{
std::stack<int> Stack;
for (int i=0; i<10; i++)
{
std::cout << "Pushing: " << i << std::endl;
Stack.push(i);
}
while (!Stack.empty())
{
std::cout << "Popping: " << Stack.top() << std::endl;
Stack.pop();
}
return 0;
}