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. The Lounge
  3. Where do you answer the QOTD?

Where do you answer the QOTD?

Scheduled Pinned Locked Moved The Lounge
sysadminquestion
8 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.
  • J Offline
    J Offline
    Jack Handy
    wrote on last edited by
    #1

    I actually use this one in my tetris server. I do it like &(*it) the () might not be needed but I think g++ likes them. So I guess answer C. On a side note it will be interesting to see if the amount of programming related questions rises in the lounge if all the QOTD's are programming related. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

    A 1 Reply Last reply
    0
    • J Jack Handy

      I actually use this one in my tetris server. I do it like &(*it) the () might not be needed but I think g++ likes them. So I guess answer C. On a side note it will be interesting to see if the amount of programming related questions rises in the lounge if all the QOTD's are programming related. -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

      A Offline
      A Offline
      Alex Deem
      wrote on last edited by
      #2

      Correct me if i am wrong, but isnt &(*it) exactly the same as just it?

      M J C 3 Replies Last reply
      0
      • A Alex Deem

        Correct me if i am wrong, but isnt &(*it) exactly the same as just it?

        M Offline
        M Offline
        markkuk
        wrote on last edited by
        #3

        Only for ordinary pointers, not iterators.

        A 1 Reply Last reply
        0
        • A Alex Deem

          Correct me if i am wrong, but isnt &(*it) exactly the same as just it?

          J Offline
          J Offline
          Jack Handy
          wrote on last edited by
          #4

          Alex Deem wrote: Correct me if i am wrong, but isnt &(*it) exactly the same as just it? it is already a pointer so you use *it to derefrence it and get the object it points to (in this case whatever object is contained in your list/vector/whatever) Then by using &(*it) you are getting a pointer to the original object contained in the list/vector/whatever. Your turn to correct me if I'm wrong :) -Jack To an optimist the glass is half full. To a pessimist the glass is half empty. To a programmer the glass is twice as big as it needs to be.

          1 Reply Last reply
          0
          • M markkuk

            Only for ordinary pointers, not iterators.

            A Offline
            A Offline
            Alex Deem
            wrote on last edited by
            #5

            Fancy explaining how and why this is different for stl iterators? :) I don't know much about stl, but i am surprised to learn the &(*it) is not the same as it! My understanding would be that it is the pointer to the object, *it dereferences and gives you the actual object within the container, &*it would then give you the original pointer. This is the behaviour for a normal pointer...what's the difference for stl iterators?

            M 1 Reply Last reply
            0
            • A Alex Deem

              Correct me if i am wrong, but isnt &(*it) exactly the same as just it?

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Under VC6, the answer is yes. But it should not be, an iterator is NOT a pointer to the object, although it behaves like one. This is fixed in VC7. Christian I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002 Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002

              1 Reply Last reply
              0
              • A Alex Deem

                Fancy explaining how and why this is different for stl iterators? :) I don't know much about stl, but i am surprised to learn the &(*it) is not the same as it! My understanding would be that it is the pointer to the object, *it dereferences and gives you the actual object within the container, &*it would then give you the original pointer. This is the behaviour for a normal pointer...what's the difference for stl iterators?

                M Offline
                M Offline
                markkuk
                wrote on last edited by
                #7

                STL iterator is a class object that overloads the * and -> operators so that it behaves like a pointer. &*it gives a regular pointer to the object referenced by the iterator, not the original iterator object.

                A 1 Reply Last reply
                0
                • M markkuk

                  STL iterator is a class object that overloads the * and -> operators so that it behaves like a pointer. &*it gives a regular pointer to the object referenced by the iterator, not the original iterator object.

                  A Offline
                  A Offline
                  Alex Deem
                  wrote on last edited by
                  #8

                  aaahhhhhhhhhhhh... It all makes sense now! Thank you :-D

                  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