PDA

View Full Version : foreach construct vs for



subdene
10-18-2003, 10:29 AM
Hello, I was just wondering what everyone would think of an implementation of the foreach statement within the c++ language. I personally find it very useful within c#, and it shortens the statements dramatically. The foreach construct is essentially the incrementation of a pointer to the type you want to iterate through. This could be done in c++ as well, but only explicitly i think, whereas the foreach does it implicitly, i.e. its behavior is hidden from the user. The foreach has its limitations though, ie. within c# you cannot traverse through an object type array, and there is no way to specify the incrementation step as well (well as far as i know). So what do you think?

twm
10-18-2003, 11:12 AM
>So what do you think?
I think you need to check out the STL for_each construct. :)

subdene
10-18-2003, 11:15 AM
oh is there one, cool. I'll be using that now.
cheers.

Fountain
10-18-2003, 01:05 PM
Yeh thats right Sub.

Dont worry about replying to my PM's you git.

Dont catch German Flu while you are over there...if it exists..hehe

Missed LG cup bud, nevermind HAHAHA.

Oh and your ex student house has been arsoned. Maybe. Hope you are cool over there :)

subdene
10-18-2003, 01:13 PM
Hello fountain,

Thank you for your reply. But you wouldn't know what stl was if it came and sat on your face. So i don't know how you can agree with twm when your a visual basic man yourself, and you don't even know what a pointer is. Best keep everything encapsulated for you eh? Theres a good dog, walkies at 10 o'clock.

Fountain
10-18-2003, 01:18 PM
Sub-If I have to tell you again!

A pointer is a DOG.

Its a crap dog 'cos they just point.

STL is obviously a STD in a different language. And you still missed the snooker you doink.

Yes it will be walkies time later, but with a Ridgeback not a pointer. Anyhow, he likes you. :)

Fountain
10-18-2003, 01:19 PM
Originally posted by twm
>So what do you think?
I think you need to check out the STL for_each construct. :)

Yeh Sub!

subdene
10-18-2003, 01:21 PM
Fountain, go tell your dog it wants you. Someone must do afterall.

Fountain
10-18-2003, 01:28 PM
To be honest Sub, I am getting a bit fed up with this 19yr old. Man, she is old now! 19!!!!!

And as you say, my mutt is only 5. Hmmm guess he too young then?

Mind, he loves his 'Dad' does the dog.

And even he knew the answer to your question.

subdene
10-18-2003, 06:10 PM
ja ja. um ehrlich zu sein werde ich nicht wirklich gestört, was Sie sagen. Gehen Wäsche Ihr Gesicht und kämmen Ihr Haar.