Reputation: 2990
I need to construct a crawler working with front_queues
and back_queues
, which are vectors of queues. I've seen solutions in this question Vector of queues but my compiler complains the vec
needs a constructor.
#include <vector>
#include <queue>
using namespace std;
vector<queue<int> > vec;
vec.push_back( queue<int>(0) );
// ^
// error: expected constructor, destructor, or type conversion before ‘.’ token
Upvotes: 1
Views: 1882
Reputation: 3389
You need to put function calls inside blocks.
Try adding a main
function :
#include <vector>
#include <queue>
using namespace std;
int main()
{
vector<queue<int> > vec;
queue<int> q;
vec.push_back(q);
return (0);
}
queue
doesn't have initializer list :
According to queue
's constructor reference (Source), you can't use queue<int>(0)
because no proper constructor would match.
However, you can use queue<int>()
. It will create an empty queue.
Take a look at this online example : https://ideone.com/RbT1pD
Upvotes: 5