Thread: foreach construct vs for

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367

    foreach construct vs for

    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?
    Be a leader and not a follower.

  2. #2
    root
    Join Date
    Sep 2003
    Posts
    232
    >So what do you think?
    I think you need to check out the STL for_each construct.
    The information given in this message is known to work on FreeBSD 4.8 STABLE.
    *The above statement is false if I was too lazy to test it.*
    Please take note that I am not a technical writer, nor do I care to become one.
    If someone finds a mistake, gleaming error or typo, do me a favor...bite me.
    Don't assume that I'm ever entirely serious or entirely joking.

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    oh is there one, cool. I'll be using that now.
    cheers.
    Be a leader and not a follower.

  4. #4
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    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
    Such is life.

  5. #5
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    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.
    Be a leader and not a follower.

  6. #6
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    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.
    Such is life.

  7. #7
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    Originally posted by twm
    >So what do you think?
    I think you need to check out the STL for_each construct.
    Yeh Sub!
    Such is life.

  8. #8
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    Fountain, go tell your dog it wants you. Someone must do afterall.
    Be a leader and not a follower.

  9. #9
    Much older and wiser Fountain's Avatar
    Join Date
    Dec 2001
    Location
    Engeeeerland
    Posts
    1,158
    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.
    Such is life.

  10. #10
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    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.
    Be a leader and not a follower.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. foreach Dictionary
    By George2 in forum C# Programming
    Replies: 1
    Last Post: 05-27-2008, 10:01 AM
  2. foreach and IEnumerator
    By George2 in forum C# Programming
    Replies: 2
    Last Post: 04-30-2008, 08:01 AM
  3. converting c code to c++, the foreach statement
    By hwttdz in forum C++ Programming
    Replies: 2
    Last Post: 07-12-2006, 11:03 AM
  4. program to construct a truth table
    By ashok varma in forum C Programming
    Replies: 2
    Last Post: 08-04-2005, 10:53 AM
  5. foreach with collections
    By Korn1699 in forum C# Programming
    Replies: 1
    Last Post: 12-03-2004, 03:12 AM