Reputation: 5
I am wondering if I can define a set of stack objects inside as part of list or vector? What I am trying to do is defining a collection of stack objects which I can get and add like normal int or float type inside one of STL containers.
For example: vector<stack> stackCollection
But it gives me error:
use of class template 'stack' requires template arguments.
Is there any way to do this in c++?
#include <iostream>
#include <stack>
#include <vector>
#include <list>
using namespace std;
int main() {
vector<stack> stackCollection;
//vector<int> stackCollection;
return 0;
}
Upvotes: 0
Views: 45
Reputation: 31
You have to specify which type the stack should contain, like this:
vector<stack<int>> stackCollection;
Upvotes: 3