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. QOTD

QOTD

Scheduled Pinned Locked Moved The Lounge
c++jsonquestionlearning
42 Posts 17 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.
  • D David Stone

    Congrats to Christian Graus for thinking up the QOTD. I believe this is the first one I've seen from a CPian. Of course, I can't answer because I haven't a clue when it comes to STL. So I'll just leave the answering of it to the rest of you. :) David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

    J Offline
    J Offline
    Jeremy Falcon
    wrote on last edited by
    #2

    That's not really Christian. That's his alter ego, Grausman, posing as him. When it comes to STL... The Grausman codeth. :) *He should get it if he reads this message. Jeremy Falcon Imputek "C# is the answer to a question nobody asked." - Chris Losinger

    1 Reply Last reply
    0
    • D David Stone

      Congrats to Christian Graus for thinking up the QOTD. I believe this is the first one I've seen from a CPian. Of course, I can't answer because I haven't a clue when it comes to STL. So I'll just leave the answering of it to the rest of you. :) David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #3

      i don't even see what i'd call the "correct" answer :( -c


      Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

      image effects!

      D 1 Reply Last reply
      0
      • C Chris Losinger

        i don't even see what i'd call the "correct" answer :( -c


        Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

        image effects!

        D Offline
        D Offline
        David Stone
        wrote on last edited by
        #4

        Well it has to be C or D right? I mean, I read the "Pointers" section in Inside C# so I know what a pointer is. So shouldn't it be C or D? David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

        C 1 Reply Last reply
        0
        • D David Stone

          Well it has to be C or D right? I mean, I read the "Pointers" section in Inside C# so I know what a pointer is. So shouldn't it be C or D? David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #5

          it's probably D. but, i've found that i'll run into trouble unless i do it like this: (*it).Foo(); in C, the precedence of "." is higher than that of "*", so *it.Foo() means *(it.Foo()), which is usually illegal. the parens forces the dereference to happen first. -c


          Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

          image effects!

          J 1 Reply Last reply
          0
          • C Chris Losinger

            it's probably D. but, i've found that i'll run into trouble unless i do it like this: (*it).Foo(); in C, the precedence of "." is higher than that of "*", so *it.Foo() means *(it.Foo()), which is usually illegal. the parens forces the dereference to happen first. -c


            Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

            image effects!

            J Offline
            J Offline
            Joel Lucsy
            wrote on last edited by
            #6

            Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)

            C R 2 Replies Last reply
            0
            • J Joel Lucsy

              Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)

              C Offline
              C Offline
              Chris Losinger
              wrote on last edited by
              #7

              heh. :) yeah, i guess that would work, too. but, i've honestly never seen that in any live code or example: it's always (*it).Foo(); -c


              Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

              image effects!

              R 1 Reply Last reply
              0
              • J Joel Lucsy

                Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)

                R Offline
                R Offline
                Ryan Johnston 0
                wrote on last edited by
                #8

                That is the whole purpose of -> Ryan Johnston

                1 Reply Last reply
                0
                • C Chris Losinger

                  heh. :) yeah, i guess that would work, too. but, i've honestly never seen that in any live code or example: it's always (*it).Foo(); -c


                  Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                  image effects!

                  R Offline
                  R Offline
                  Ryan Johnston 0
                  wrote on last edited by
                  #9

                  Chris Losinger wrote: but, i've honestly never seen that in any live code or example: it's always (*it).Foo(); Are you serious? I have never ever seen someone use (*it).Foo() instead of it->Foo(). Pointers would be so dirty without ->. Ryan Johnston

                  C C 2 Replies Last reply
                  0
                  • D David Stone

                    Congrats to Christian Graus for thinking up the QOTD. I believe this is the first one I've seen from a CPian. Of course, I can't answer because I haven't a clue when it comes to STL. So I'll just leave the answering of it to the rest of you. :) David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

                    R Offline
                    R Offline
                    Ryan Johnston 0
                    wrote on last edited by
                    #10

                    I don't know anything about STL, what is an STL iterator? Having said that the only option that look reasonable is D (although other options are possible if iterators have overloaded operators). Ryan Johnston

                    M 1 Reply Last reply
                    0
                    • R Ryan Johnston 0

                      Chris Losinger wrote: but, i've honestly never seen that in any live code or example: it's always (*it).Foo(); Are you serious? I have never ever seen someone use (*it).Foo() instead of it->Foo(). Pointers would be so dirty without ->. Ryan Johnston

                      C Offline
                      C Offline
                      Chris Losinger
                      wrote on last edited by
                      #11

                      Ryan Johnston wrote: Are you serious? yes, 100%. -c


                      Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                      image effects!

                      R D 2 Replies Last reply
                      0
                      • C Chris Losinger

                        Ryan Johnston wrote: Are you serious? yes, 100%. -c


                        Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                        image effects!

                        R Offline
                        R Offline
                        Ryan Johnston 0
                        wrote on last edited by
                        #12

                        Wow, interesting... I guess the only difference is one keystroke, but I am just surprised. What kind of programming do you do? Ryan Johnston

                        C 1 Reply Last reply
                        0
                        • R Ryan Johnston 0

                          Wow, interesting... I guess the only difference is one keystroke, but I am just surprised. What kind of programming do you do? Ryan Johnston

                          C Offline
                          C Offline
                          Chris Losinger
                          wrote on last edited by
                          #13

                          there's probably some deep metaphysical reason why people want to use (*it). instead of it-> . i just do it because that's how i learned it. Ryan Johnston wrote: What kind of programming do you do? a little of everything, but mostly 2d graphics. -c


                          Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                          image effects!

                          C D 2 Replies Last reply
                          0
                          • D David Stone

                            Congrats to Christian Graus for thinking up the QOTD. I believe this is the first one I've seen from a CPian. Of course, I can't answer because I haven't a clue when it comes to STL. So I'll just leave the answering of it to the rest of you. :) David Stone It seemed similar to someone saying, "Would you like to meet my knife collection?" Ryan Johnston on Elaine's sig

                            N Offline
                            N Offline
                            Nemanja Trifunovic
                            wrote on last edited by
                            #14

                            The answer is C) (*it) is the value, so &(*it) is the address of the value. Or did I miss something? I vote pro drink :beer:

                            S C P C 4 Replies Last reply
                            0
                            • C Chris Losinger

                              Ryan Johnston wrote: Are you serious? yes, 100%. -c


                              Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                              image effects!

                              D Offline
                              D Offline
                              David Wulff
                              wrote on last edited by
                              #15

                              :omg:


                              David Wulff http://www.davidwulff.co.uk

                              One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.

                              C 1 Reply Last reply
                              0
                              • N Nemanja Trifunovic

                                The answer is C) (*it) is the value, so &(*it) is the address of the value. Or did I miss something? I vote pro drink :beer:

                                S Offline
                                S Offline
                                Shog9 0
                                wrote on last edited by
                                #16

                                Nemanja Trifunovic wrote: Or did I miss something? No, you are correct. Any other way is less safe.

                                ---

                                Shog9 If I could sleep forever, I could forget about everything...

                                1 Reply Last reply
                                0
                                • C Chris Losinger

                                  there's probably some deep metaphysical reason why people want to use (*it). instead of it-> . i just do it because that's how i learned it. Ryan Johnston wrote: What kind of programming do you do? a little of everything, but mostly 2d graphics. -c


                                  Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                                  image effects!

                                  C Offline
                                  C Offline
                                  Colin Leitner
                                  wrote on last edited by
                                  #17

                                  Looking into the MSDN can open eyes! iterator overloads operator*. plain and simple. Somehow the STL trys to use references wherever possible.

                                  C 1 Reply Last reply
                                  0
                                  • D David Wulff

                                    :omg:


                                    David Wulff http://www.davidwulff.co.uk

                                    One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.

                                    C Offline
                                    C Offline
                                    Chris Losinger
                                    wrote on last edited by
                                    #18

                                    sadly, that used up the last of my "serious" for today. time for beer. -c


                                    Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                                    image effects!

                                    D 1 Reply Last reply
                                    0
                                    • C Chris Losinger

                                      sadly, that used up the last of my "serious" for today. time for beer. -c


                                      Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                                      image effects!

                                      D Offline
                                      D Offline
                                      David Wulff
                                      wrote on last edited by
                                      #19

                                      lol. :)


                                      David Wulff http://www.davidwulff.co.uk

                                      One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.

                                      1 Reply Last reply
                                      0
                                      • N Nemanja Trifunovic

                                        The answer is C) (*it) is the value, so &(*it) is the address of the value. Or did I miss something? I vote pro drink :beer:

                                        C Offline
                                        C Offline
                                        Colin Leitner
                                        wrote on last edited by
                                        #20

                                        Correct :D! Altough I believe the questioner ment D).

                                        1 Reply Last reply
                                        0
                                        • C Colin Leitner

                                          Looking into the MSDN can open eyes! iterator overloads operator*. plain and simple. Somehow the STL trys to use references wherever possible.

                                          C Offline
                                          C Offline
                                          Chris Losinger
                                          wrote on last edited by
                                          #21

                                          Colin Leitner wrote: plain and simple what's plain and simple? *it.menuItem // does not compile (*it).menuItem // compiles nicely -c


                                          Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten

                                          image effects!

                                          C 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