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