home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 May
/
VPR9705A.ISO
/
VPR_DATA
/
PROGRAM
/
CBTRIAL
/
SETUP
/
DATA.Z
/
STACK.CPP
< prev
next >
Wrap
Text File
|
1997-02-14
|
815b
|
47 lines
#include <stack>
#include <vector>
#include <deque>
#include <string>
using namespace std;
int main ()
{
//
// Make a stack using a vector container.
//
stack<int,vector<int> > s;
//
// Push a couple of values on the stack.
//
s.push(1);
s.push(2);
cout << s.top() << endl;
//
// Now pop them off.
//
s.pop();
cout << s.top() << endl;
s.pop();
//
// Make a stack of strings using a deque.
//
stack<string,deque<string> > ss;
//
// Push a bunch of strings on then pop them off.
//
int i;
for (i = 0; i < 10; i++)
{
ss.push(string(i+1,'a'));
cout << ss.top() << endl;
}
for (i = 0; i < 10; i++)
{
cout << ss.top() << endl;
ss.pop();
}
return 0;
}