C++:为什么我不能创建结构的队列?

C++: why can't i make a queue of a struct?

本文关键字:结构 队列 创建 不能 为什么 C++      更新时间:2023-10-16

我有以下代码:

        #include <queue>
        struct Job                  
        {
        };
        queue<Job> _jobQueue;

但我得到了错误:

error: ISO C++ forbids declaration of âqueueâ with no type

如何为结构创建队列?

您没有#include <queue>

编辑:编辑后,您需要将其限定为std::queue<Job>

尝试以下

std::queue<Job> _jobQueue;