moatPylon
moatPylon

Reputation: 2191

Using STL's list object

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)

Upvotes: 4

Views: 602

Answers (2)

Ben Voigt
Ben Voigt

Reputation: 283971

also "using namespace std", and there needs to be a semicolon after your class definition

280Z28 is right that "using" in a header file is a bad idea for production code. It's still a reasonable troubleshooting step though, to quickly see if the primary problem is identifier search scope.

Upvotes: 1

Sam Harwell
Sam Harwell

Reputation: 100059

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;

Upvotes: 7

Related Questions