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. Now, how to delete?

Now, how to delete?

Scheduled Pinned Locked Moved C / C++ / MFC
questioncomtoolshelptutorial
11 Posts 4 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.
  • A Astricks

    Please Refer Here[^] This doesn't work there:

    if (mySObj_iter != lst_mySObj.end())
    {
    lst_mySObj.erase(*mySObj_iter);
    }

    How do I do it?Overload any other operator?:confused: Error: error C2664: 'std::list<_Ty>::_Iterator<_Secure_validation> std::list<_Ty>::erase(std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'myStruct' to 'std::list<_Ty>::_Iterator<_Secure_validation>' with [ _Ty=myStruct_t, _Secure_validation=true ]

    *

    J Offline
    J Offline
    jhwurmbach
    wrote on last edited by
    #2

    Astricks wrote:

    lst_mySObj.erase(*mySObj_iter);

    Did you even bother to read the MSDN helptext? Or a good Book? Josuttis, "The C++ Standard Library" and Myers, "Effective STL" are always within arms lenght here. The correct parameter is the iterator, not the object. So stop dereferencing the iterator and write lst_mySObj.erase(mySObj_iter); -- moified at 4:43 Monday 12th February, 2007 Clarification


    "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

    A H 3 Replies Last reply
    0
    • A Astricks

      Please Refer Here[^] This doesn't work there:

      if (mySObj_iter != lst_mySObj.end())
      {
      lst_mySObj.erase(*mySObj_iter);
      }

      How do I do it?Overload any other operator?:confused: Error: error C2664: 'std::list<_Ty>::_Iterator<_Secure_validation> std::list<_Ty>::erase(std::list<_Ty>::_Iterator<_Secure_validation>)' : cannot convert parameter 1 from 'myStruct' to 'std::list<_Ty>::_Iterator<_Secure_validation>' with [ _Ty=myStruct_t, _Secure_validation=true ]

      *

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #3

      have you tried using this :

      lst_mySObj.erase(mySObj_iter); //see, the iterator is not dereferenced

      if i remember well, erase() gets an iterator, not an element of the vector also, if you're cleaning the whole vector, use clear() instead


      [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

      A 1 Reply Last reply
      0
      • T toxcct

        have you tried using this :

        lst_mySObj.erase(mySObj_iter); //see, the iterator is not dereferenced

        if i remember well, erase() gets an iterator, not an element of the vector also, if you're cleaning the whole vector, use clear() instead


        [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

        A Offline
        A Offline
        Astricks
        wrote on last edited by
        #4

        Thanks toxcct :D

        *

        1 Reply Last reply
        0
        • J jhwurmbach

          Astricks wrote:

          lst_mySObj.erase(*mySObj_iter);

          Did you even bother to read the MSDN helptext? Or a good Book? Josuttis, "The C++ Standard Library" and Myers, "Effective STL" are always within arms lenght here. The correct parameter is the iterator, not the object. So stop dereferencing the iterator and write lst_mySObj.erase(mySObj_iter); -- moified at 4:43 Monday 12th February, 2007 Clarification


          "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

          A Offline
          A Offline
          Astricks
          wrote on last edited by
          #5

          Thanks. I'm handling struct objects inside vectors for the first time. So the panic.

          *

          J 1 Reply Last reply
          0
          • J jhwurmbach

            Astricks wrote:

            lst_mySObj.erase(*mySObj_iter);

            Did you even bother to read the MSDN helptext? Or a good Book? Josuttis, "The C++ Standard Library" and Myers, "Effective STL" are always within arms lenght here. The correct parameter is the iterator, not the object. So stop dereferencing the iterator and write lst_mySObj.erase(mySObj_iter); -- moified at 4:43 Monday 12th February, 2007 Clarification


            "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

            A Offline
            A Offline
            Astricks
            wrote on last edited by
            #6

            I voted you up, but it greyed :confused:

            *

            1 Reply Last reply
            0
            • A Astricks

              Thanks. I'm handling struct objects inside vectors for the first time. So the panic.

              *

              J Offline
              J Offline
              jhwurmbach
              wrote on last edited by
              #7

              Astricks wrote:

              So the panic.

              No Problem. I followed your link only after my post, to see that you are actually caring for the answers. Therefore I was pointing you to the documentation before answerinf your question. But really, the Josuttis helps greatly when working with the STL. And the Myers is great in giving lectures about dos and donts with the STL.


              "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

              1 Reply Last reply
              0
              • J jhwurmbach

                Astricks wrote:

                lst_mySObj.erase(*mySObj_iter);

                Did you even bother to read the MSDN helptext? Or a good Book? Josuttis, "The C++ Standard Library" and Myers, "Effective STL" are always within arms lenght here. The correct parameter is the iterator, not the object. So stop dereferencing the iterator and write lst_mySObj.erase(mySObj_iter); -- moified at 4:43 Monday 12th February, 2007 Clarification


                "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #8

                I dont know why you get low vote I give 5 to you ;)


                WhiteSky


                J 1 Reply Last reply
                0
                • H Hamid Taebi

                  I dont know why you get low vote I give 5 to you ;)


                  WhiteSky


                  J Offline
                  J Offline
                  jhwurmbach
                  wrote on last edited by
                  #9

                  Someone does not share my taste in books? :-D Anyway - thanks! :rose:


                  "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                  H T 2 Replies Last reply
                  0
                  • J jhwurmbach

                    Someone does not share my taste in books? :-D Anyway - thanks! :rose:


                    "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                    H Offline
                    H Offline
                    Hamid Taebi
                    wrote on last edited by
                    #10

                    Sometimes I going to meet of new ideas on your mail you answer and suggest a book to him its worth:-D


                    WhiteSky


                    1 Reply Last reply
                    0
                    • J jhwurmbach

                      Someone does not share my taste in books? :-D Anyway - thanks! :rose:


                      "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                      T Offline
                      T Offline
                      toxcct
                      wrote on last edited by
                      #11

                      or maybe just the way you suggested it, implying that the OP didn't search first. i personnaly found the tone of your post a bit aggressive, so i can understand someone else did too...


                      [VisualCalc][Flags Beginner's Guide] | [Forums Guidelines][My Best Advice]

                      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