Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem removing object from list

Problem removing object from list

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpvisual-studiosysadminwindows-admin
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kevin Brydon
    wrote on last edited by
    #1

    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

    C 1 Reply Last reply
    0
    • K Kevin Brydon

      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

      C Offline
      C Offline
      Cedric Moonen
      wrote on last edited by
      #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]

      K 1 Reply Last reply
      0
      • C Cedric Moonen

        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]

        K Offline
        K Offline
        Kevin Brydon
        wrote on last edited by
        #3

        ah thats solved my problem. i thought the == operator was implicitly defined to check if two objects were equal thanks kevin

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups