Click to See Complete Forum and Search --> : foreach in C++?
leguignol
December 31st, 2005, 07:09 AM
Hi!
Does somebody know a function in C++.NET that is similar to the function "foreach" in Csharp?
Leguignol
NoHero
December 31st, 2005, 07:33 AM
The C++ does not have a for each construct. You can easily rebuild it using a for loop.
darwen
December 31st, 2005, 07:57 AM
I think C++/CLI (i.e. under DevStudio 2005) has foreach as a keyword, but I might be mistaken.
Darwen.
Andreas Masur
December 31st, 2005, 12:21 PM
Does somebody know a function in C++.NET that is similar to the function "foreach" in Csharp?
ANSI C++ does have the STL algorithm 'for_each'
C++/CLI does have a 'for each' keyword
cilu
January 3rd, 2006, 10:19 AM
If by C++.Net you mean C++/CLI then check the "Iterating over Collections" paragraph from this article (http://www.codeguru.com/Cpp/Cpp/cpp_managed/general/article.php/c10653/).
codeguru.com
Copyright WebMediaBrands Inc., All Rights Reserved.