[英]Priority Queue Compilation Error
我正在嘗試編譯下面的代碼,但編譯器給出了錯誤
Struct.h:38:9: error: ‘priority_queue’ in namespace ‘std’ does not name a type
幾次搜索未能透露答案,所以我希望你們能幫忙。 該代碼部分基於c ++參考站點上給出的示例代碼。
struct aimedShot;
union moveFunc;
struct timeCommand;
struct aimedShot
{
void (*move) (Dot*, SDL_Event&, double x, double y);
double x;
double y;
};
//Holds the kind of function used
union moveFunc
{
void (*notAimed) (Dot*);
aimedShot aimed;
};
//Dot to be operated on and the appropriate operator with time
struct timeCommand
{
Dot* target;
moveFunc command;
int time;
bool type; //True indicates aimed (integer inputs), False indicates unaimed
};
class CompareCommand
{
public:
bool operator()(timeCommand& c1, timeCommand& c2) //Return true if c1 comes first
{
return (c1.time < c2.time);
}
};
typedef std::priority_queue< timeCommand, std::vector<timeCommand>, CompareCommand> commandTimeline;
為了能夠使用std::priority_queue<>
類模板,您需要#include <queue>
標准頭。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.