QOTD
-
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
Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)
-
Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)
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
-
Why not it->Foo(); Joel Lucsy (jjlucsy@ameritech.net)
That is the whole purpose of -> Ryan Johnston
-
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
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
-
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
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
-
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
Ryan Johnston wrote: Are you serious? yes, 100%. -c
Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten
-
Ryan Johnston wrote: Are you serious? yes, 100%. -c
Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten
Wow, interesting... I guess the only difference is one keystroke, but I am just surprised. What kind of programming do you do? Ryan Johnston
-
Wow, interesting... I guess the only difference is one keystroke, but I am just surprised. What kind of programming do you do? Ryan Johnston
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
-
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
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:
-
Ryan Johnston wrote: Are you serious? yes, 100%. -c
Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten
:omg:
David Wulff http://www.davidwulff.co.uk
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
-
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:
-
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
Looking into the MSDN can open eyes! iterator overloads operator*. plain and simple. Somehow the STL trys to use references wherever possible.
-
:omg:
David Wulff http://www.davidwulff.co.uk
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
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
-
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:
Correct :D! Altough I believe the questioner ment D).
-
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
lol. :)
David Wulff http://www.davidwulff.co.uk
One 18yrs male, red and white, good condition; daily servicing required. £500 collect ono.
-
Looking into the MSDN can open eyes! iterator overloads operator*. plain and simple. Somehow the STL trys to use references wherever possible.
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
-
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
iterator is a struct. now operator* returns the value (if I understood that right). so you need it.operator*().menuItem or (*it).menuItem. This has nothing to do with any pointer syntax.
-
iterator is a struct. now operator* returns the value (if I understood that right). so you need it.operator*().menuItem or (*it).menuItem. This has nothing to do with any pointer syntax.
but it has a lot to do with precedence. overloading an operator, such as "*" doesn't change its precedence. -c
Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten
-
but it has a lot to do with precedence. overloading an operator, such as "*" doesn't change its precedence. -c
Conservative: One who admires radicals centuries after they're dead. -- Leo C. Rosten
Yes but '->' won't work at all! You cannot change operator precedence at all, that's correct. a+++++b ;)
-
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: