QUOTE(horace @ 29 Oct, 2006 - 01:57 PM)

the output would be
22 8 3
with y=8 and x=3
program with explaination
CODE
#include <iostream>
#include <stack>
using namespace std;
int main()
{
stack<int> intStack;
int x, y=3;
intStack.push(8); // push 8
intStack.push(9); // push 9
intStack.push(y); // push y (3)
x= intStack.top(); // x is 3 (top of stack)
intStack.pop(); // pop 3
intStack.pop(); // pop 9
intStack.push(22); // push 22
// two items on stack 22 (top) and 8
while(!intStack.empty())
{y=intStack.top(); // y is top of stack
// - in first loop y is 22 second loop y is 8
intStack.pop(); // pop top of stack
cout<<y<<" "; // print y is 22 then 8
}
cout<<x<<endl; // print x is 3
cin.get();
cin.get();
return 0;
}
thank you horace for the walk through of these codes i now have a better understanding.