Question about STL stack
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

