"for each" is not supported by vs2005 beta?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi.

I heard that vs2005 vc++ support the "for each" statement.
I try it in vs2005 by creating a dotnet c++ console program.
The code is:
#using <System.dll>
using namespace System;
using namespace stdcli::language;
void main(){
array<int>^ ary1 = gcnew array<int>(4){1,2,3,4};
for each(int i in ary1)
Console::WriteLine(i);
}
But the compiler told me:
error C2061: syntax error : identifier 'each'
Is that error in my code? or the beta version doesn't support "for each"??
 
I have saw a demo on ms's WebCast. I am sure the code is correct and "for each" is two words. But I don't know why it can't be compiled. :<
 
aska said:
Hi.

I heard that vs2005 vc++ support the "for each" statement.
I try it in vs2005 by creating a dotnet c++ console program.
The code is:
#using <System.dll>
using namespace System;
using namespace stdcli::language;
void main(){
array<int>^ ary1 = gcnew array<int>(4){1,2,3,4};
for each(int i in ary1)
Console::WriteLine(i);
}
But the compiler told me:
error C2061: syntax error : identifier 'each'
Is that error in my code? or the beta version doesn't support "for each"??

As far as I can tell from playing with Beta 1, there appears to be no
support for a C#-style foreach.
Can you share the source of the information you got that indicated such
support would be included?
 
The syntax you have should be right... I haven't downloaded beta 1 yet (way
too big for me right now), but I know that it does compile on the compiler
build I have right now installed...

--
Tomas Restrepo
(e-mail address removed)


aska said:
I have saw a demo on ms's WebCast. I am sure the code is correct and "for
each" is two words. But I don't know why it can't be compiled. :<
 
Carl said:
It's not in Beta 1, but it should be in Beta 2.

Right. Our development schedule for some of the C++ features was a bit
strange. We forked our development earlier this year while most of Visual
Studio started locking down for Beta 1. Thus, a number of C++ features
didn't make it into Beta 1.

They will all be in Beta 2. We are also working on release of the C++
compiler directly out of our development branch. That should be available as
soon as we figure out the logistics.
 
Back
Top