I am trying to implement a set to store game objects and use the game attribute gameNum as a key to the set.
I have overloaded the operator in the Game.cpp file as per below:
then in another class I have a STL set of games to which I insertCode:bool Game::operator<(Const Game& rhs)const { if(gameNum < rhs.gameNum) { return true; } return false; }
all the games (inserting is working fine) .
once the set is filled with games and I try to retrieve one with findCode:set<Game*>schedule; set<Game*>::iterator si;
where gameToPlay is an int as is gameNumCode:si=schedule.find(gameToPlay);
this gives me the error message:
Invalid conversion from int to game - which I thought my overloaded operator made the key int??
Is that correct and I am not calling it correctly
or havent declared something correctly I am unsure.
Any input appreciated
Regards



LinkBack URL
About LinkBacks


