Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using STL's list object

Tags:

c++

stl

I want to create a list of queues in C++ but the compiler gives me some cryptic messages:

#include <list>
#include <queue>

class Test
{
    [...]
    list<queue> list_queue;
    [...]
}

Output:

error C2143: syntax error : missing ';' before '<'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2238: unexpected token(s) preceding ';'

It gives me the same error even if I use int as the template paramenter. What's going on?

(btw, I'm using VC++ 2008 EE)

like image 317
moatPylon Avatar asked Jan 23 '23 12:01

moatPylon


1 Answers

queue is a template class as well, so you'll need to specify the element type contained in your queues. Also, - is not a legal identifier character in C++; perhaps you meant _?

std::list<std::queue<SOME_TYPE_HERE> > list_queue;
like image 121
Sam Harwell Avatar answered Jan 25 '23 02:01

Sam Harwell