Problem removing object from list
-
Hi, I am having trouble removing an object from a std::list. I have got a Line object and a list structure in the form std::list lines; and am trying to remove a particular Line object from the list by Line * selectedLine; // code to determine what line is selected lines.remove(*selectedLine); I get the error c:\program files\microsoft visual studio 8\vc\include\list(908) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Line' (or there is no acceptable conversion) c:\program files\microsoft platform sdk for windows server 2003 r2\include\guiddef.h(192): could be 'int operator ==(const GUID &,const GUID &)' [found using argument-dependent lookup] while trying to match the argument list '(Line, const Line)' c:\program files\microsoft visual studio 8\vc\include\list(898) : while compiling class template member function 'void std::list<_Ty>::remove(const _Ty &)' with [ _Ty=Line ] c:\documents and settings\kevin\my documents\visual studio 2005\projects\sdl_001\sdl_001\main.h(391) : see reference to class template instantiation 'std::list<_Ty>' being compiled with [ _Ty=Line ] I have tried searching google but all I can find is examples of how to remove integers and strings from lists Any help would be appreciated Kevin
-
Hi, I am having trouble removing an object from a std::list. I have got a Line object and a list structure in the form std::list lines; and am trying to remove a particular Line object from the list by Line * selectedLine; // code to determine what line is selected lines.remove(*selectedLine); I get the error c:\program files\microsoft visual studio 8\vc\include\list(908) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'Line' (or there is no acceptable conversion) c:\program files\microsoft platform sdk for windows server 2003 r2\include\guiddef.h(192): could be 'int operator ==(const GUID &,const GUID &)' [found using argument-dependent lookup] while trying to match the argument list '(Line, const Line)' c:\program files\microsoft visual studio 8\vc\include\list(898) : while compiling class template member function 'void std::list<_Ty>::remove(const _Ty &)' with [ _Ty=Line ] c:\documents and settings\kevin\my documents\visual studio 2005\projects\sdl_001\sdl_001\main.h(391) : see reference to class template instantiation 'std::list<_Ty>' being compiled with [ _Ty=Line ] I have tried searching google but all I can find is examples of how to remove integers and strings from lists Any help would be appreciated Kevin
I never used remove before but I suppose that you need to supply an ==operator for your Line class. Otherwise, the compiler cannot know if two Line objects are the same.
Cédric Moonen Software developer
Charting control [v1.2] -
I never used remove before but I suppose that you need to supply an ==operator for your Line class. Otherwise, the compiler cannot know if two Line objects are the same.
Cédric Moonen Software developer
Charting control [v1.2]ah thats solved my problem. i thought the == operator was implicitly defined to check if two objects were equal thanks kevin