使用STL的列表对象

moa*_*lon 4 c++ stl

我想用C++创建一个队列列表,但编译器给了我一些神秘的消息:

#include <list>
#include <queue>

class Test
{
    [...]
    list<queue> list_queue;
    [...]
}
Run Code Online (Sandbox Code Playgroud)

输出:

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 ';'
Run Code Online (Sandbox Code Playgroud)

即使我使用int作为模板参数,它也会给出相同的错误.这是怎么回事?

(顺便说一下,我正在使用VC++ 2008 EE)

Sam*_*ell 8

queue也是一个模板类,因此您需要指定队列中包含的元素类型.此外,-它不是C++中的合法标识符字符; 也许你的意思_

std::list<std::queue<SOME_TYPE_HERE> > list_queue;
Run Code Online (Sandbox Code Playgroud)