Question about STL stack

Hi, everyone!

When using stack in STL, I meet with the following trouble.
Here are the source codes and related error messages. How to
resolve the trouble? My IDE is VC6.0.

Source Codes:
---
#include <iostream>
#include <vector>
#include <list>
#include <deque>
#include <stack>

using namespace std;

int main()
{
stack<vector<int> > s1;
stack<list<int> > s2;
stack<deque<int> > s3;

s1.push(1); s1.push(5);
cout << s1.top() << endl;
s1.pop();
cout << s1.size() << endl;
s1.empty()? cout << "empty" : cout << "not empty";

return 0;
}
---

Error messages:
---
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(15) : error C2664: 'push' : cannot convert

parameter 1 from 'const int' to 'const class std::vector<int,class std::allocator<int> > &'
Reason: cannot convert from 'const int' to 'const class std::vector<int,class std::allocator<int> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(15) : error C2664: 'push' : cannot convert

parameter 1 from 'const int' to 'const class std::vector<int,class std::allocator<int> > &'
Reason: cannot convert from 'const int' to 'const class std::vector<int,class std::allocator<int> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
C:\Program Files\Microsoft Visual Studio\MyProjects\testStack\testStack.cpp(16) : error C2679: binary '<<' : no operator

defined which takes a right-hand operand of type 'class std::vector<int,class std::allocator<int> >' (or there is no

acceptable
conversion)
---

Thanks in advance,
George
[2220 byte] By [George2] at [2007-11-18 2:14:04]
# 1 Re: Question about STL stack
"s1" is a stack of vector<int>. You are trying to push ints onto it.

#include <stack>
#include <vector>

using namespace std;

int main()
{
stack<vector<int> > s1;

vector<int> v1;

v1.push_back(1);
v1.push_back(5);
s1.push(v1);
}

or

#include <stack>

using namespace std;

int main()
{
stack<int> s1;

s1.push(1);
s1.push(5);
}

If you're meaning to alter the underlying container within the stack, then that's the second template parameter:

stack<int, vector<int> > s1;
Graham at 2007-11-8 1:17:58 >
# 2 Re: Question about STL stack
Thanks, Graham buddies!

George
Originally posted by Graham
"s1" is a stack of vector<int>. You are trying to push ints onto it.

#include <stack>
#include <vector>

using namespace std;

int main()
{
stack<vector<int> > s1;

vector<int> v1;

v1.push_back(1);
v1.push_back(5);
s1.push(v1);
}

or

#include <stack>

using namespace std;

int main()
{
stack<int> s1;

s1.push(1);
s1.push(5);
}

If you're meaning to alter the underlying container within the stack, then that's the second template parameter:

stack<int, vector<int> > s1;
George2 at 2007-11-8 1:18:55 >