所以,我正试图创建一个结构体TileSet
并重载<
运算符,然后将TileSet
放入优先队列中。我读到过我不能在const引用上调用非const方法,但实际上不应该有问题,我只是访问成员而不是更改它们:
struct TileSet
{
// ... other struct stuff, the only stuff that matters
TileSet(const TileSet& copy)
{
this->gid = copy.gid;
this->spacing = copy.spacing;
this->width = copy.width;
this->height = copy.height;
this->texture = copy.texture;
}
bool operator<(const TileSet &b)
{
return this->gid < b.gid;
}
};
错误信息告诉我: 传递 'const TileSet' 作为 'bool TileSet::operator<(const TileSet&)' 的 'this' 参数会丢弃限定符[-fpermissive]。这是什么意思?将变量更改为const并没有起作用,而且我需要它们是非const的。当我尝试执行以下操作时发生错误:
std :: priority_queue <be :: Object :: TileSet> tileset_queue;
。