的僞代碼(這是我的課):矢量==操作符
struct cTileState {
cTileState(unsigned int tileX, unsigned int tileY, unsigned int texNr) : tileX(tileX), tileY(tileY), texNr(texNr) {}
unsigned int tileX;
unsigned int tileY;
unsigned int texNr;
bool operator==(const cTileState & r)
{
if (tileX == r.tileX && tileY == r.tileY && texNr == r.texNr) return true;
else return false;
}
};
然後,我有兩個容器:
std::list < std::vector <cTileState> > changesList; //stores states in specific order
std::vector <cTileState> nextState;
而且某處PROGRAMM我想做的事情在我的國家交換功能:
if (nextState == changesList.back()) return;
然而,當我想編譯它,我有一些毫無意義的,我的錯誤,如:
/usr/include/c++/4.7/bits/stl_vector.h:1372:58: required from ‘bool std::operator==(const std::vector<_Tp, _Alloc>&, const std::vector<_Tp, _Alloc>&) [with _Tp = cMapEditor::cActionsHistory::cTileState; _Alloc = std::allocator]’
error: passing ‘const cMapEditor::cActionsHistory::cTileState’ as ‘this’ argument of ‘bool cMapEditor::cActionsHistory::cTileState::operator==(const cMapEditor::cActionsHistory::cTileState&)’ discards qualifiers [-fpermissive]
它說什麼是錯在stl_vector.h和我不尊重const的預選賽,但老實說,有沒有,我不尊重const的預選賽。這裏有什麼問題?
更重要的是,IDE不顯示我的任何特定行的錯誤在我的文件 - 它只是顯示在構建日誌,這一切。
錯誤永遠不會毫無意義。 –
對,我改變了。 – user1873947