在 C++ 中声明队列
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19754593/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Declaring queue in c++
提问by zalyahya
I'm trying to declare a queue in c++:
我试图在 C++ 中声明一个队列:
#include <queue>
......
......
queue<Process> *readyQueue = new queue<Process>;
.......
But i keep getting this error
但我不断收到这个错误
'queue' was not declared in this scope
“队列”未在此范围内声明
What am I missing? I, of course, created the Process struct, so the problem isn't there. What's the issue?
我错过了什么?当然,我创建了 Process 结构,所以问题不存在。有什么问题?
回答by klm123
You are missing namespace specification. I suppose you want std functions. Use either:
您缺少命名空间规范。我想你想要 std 函数。使用:
#include <queue>
......
std::queue<Process> *readyQueue = new std::queue<Process>;
or
或者
#include <queue>
using std::queue;
......
queue<Process> *readyQueue = new queue<Process>;
回答by John Dibling
You need to specify the correct namespace
您需要指定正确的命名空间
std::queue
std::queue