我试图编译下面的代码,但编译器报错。
Struct.h:38:9: error: ‘priority_queue’ in namespace ‘std’ does not name a type
我希望你能帮忙翻译一下,因为涉及到IT技术,我需要的是更加通俗易懂的文字。我搜索了很多次但没有找到答案,所以希望你们可以帮忙解决。这段代码部分基于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;