Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
stack.cpp
Go to the documentation of this file.
1
29#include <stack>
30#include <vector>
31#include <deque>
32#include <string>
33#include <iostream>
34
35int main ()
36{
37#ifndef _RWSTD_NO_NAMESPACE
38 using namespace std;
39#endif
40
41 //
42 // Make a stack using a vector container.
43 //
44 stack<int,vector<int,allocator<int> > > s;
45 //
46 // Push a couple of values on the stack.
47 //
48 s.push(1);
49 s.push(2);
50 cout << s.top() << endl;
51 //
52 // Now pop them off.
53 //
54 s.pop();
55 cout << s.top() << endl;
56 s.pop();
57 //
58 // Make a stack of strings using a deque.
59 //
60 stack<string,deque<string,allocator<string> > > ss;
61 //
62 // Push a bunch of strings on then pop them off.
63 //
64 int i;
65 for (i = 0; i < 10; i++)
66 {
67 ss.push(string(i+1,'a'));
68 cout << ss.top() << endl;
69 }
70 for (i = 0; i < 10; i++)
71 {
72 cout << ss.top() << endl;
73 ss.pop();
74 }
75
76 return 0;
77}
#define i
Definition 17.names.cpp:126
#define s
Definition json.h:5363
int main()
Definition stack.cpp:35