By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,255 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

"for each" is not supported by vs2005 beta?

P: n/a
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"??
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
foreach (one word) maybe as in C#?

/LM

"aska" <as**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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"??

Nov 17 '05 #2

P: n/a
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. :<

"Luc E. Mistiaen" wrote:
foreach (one word) maybe as in C#?

/LM

"aska" <as**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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"??


Nov 17 '05 #3

P: n/a

"aska" <as**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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?

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 17 '05 #4

P: n/a
I got this information from
MSDN Webcast: The New C++: Introduction to the New C++ , April 28
by Brandon Bray.
http://www.placeware.com/cc/msevents...646&pw=webcast

The demo of "for each" construct is at 52:30.

"Peter van der Goes" wrote:

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?

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.

Nov 17 '05 #5

P: n/a
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
to****@mvps.org
"aska" <as**@discussions.microsoft.com> wrote in message
news:1D**********************************@microsof t.com...
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. :<
"Luc E. Mistiaen" wrote:
foreach (one word) maybe as in C#?

/LM

"aska" <as**@discussions.microsoft.com> wrote in message
news:FA**********************************@microsof t.com...
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"??

Nov 17 '05 #6

P: n/a
aska wrote:
I got this information from
MSDN Webcast: The New C++: Introduction to the New C++ , April 28
by Brandon Bray.
http://www.placeware.com/cc/msevents...646&pw=webcast

The demo of "for each" construct is at 52:30.


It's not in Beta 1, but it should be in Beta 2.

-cd
Nov 17 '05 #7

P: n/a
Carl Daniel [VC++ MVP] wrote:

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.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.