Re: Porting from VC6 to VS2005
- From: "Giovanni Dicanio" <giovanniDOTdicanio@xxxxxxxxxxxxxxxxx>
- Date: Sat, 27 Sep 2008 17:08:06 +0200
"AVee" <AVee@xxxxxxxxxxxxxxxx> ha scritto nel messaggio news:%23GLBX7KIJHA.4240@xxxxxxxxxxxxxxxxxxxxxxx
In the mean time, I am interested in the loop scoping differences. Do you have a link to some info that you could quickly include?
I think that David refers to this:
Sample code snippet:
for ( int i = 0; i < N; i++ )
{
....
}
printf( "i = %d\n", i );
In VC6, the loop index 'i' has a scope outside the for loop, and you can use 'i' value like in printf above.
i.e. the above code is like this:
int i;
for ( i = 0; i < N; i++ )
...
printf( "i = %d\n", i );
Instead, new C++ standard considers 'i' as having a scope inside for loop, such that the initial for code corresponds to something like this:
{
int i;
for ( i = 0; i < N; i++ )
...
}
// You can't use 'i' here
printf( "i = %d\n", i ); // <<-- error
The new C++ standard allows you to write code like this:
for ( int i = 0; i < N; i++ )
...
for ( int i = 0; i < M; i++ )
...
for ( int i = 0; i < L; i++ )
...
because 'i' does not exist anymore when each of the for loop terminates.
Instead, you could not write code like this with VC6: you hade 'i' redefinition error.
HTH,
Giovanni
.
- Follow-Ups:
- Re: Porting from VC6 to VS2005
- From: Joseph M . Newcomer
- Re: Porting from VC6 to VS2005
- References:
- Porting from VC6 to VS2005
- From: AVee
- Re: Porting from VC6 to VS2005
- From: Ian Semmel
- Re: Porting from VC6 to VS2005
- From: David Wilkinson
- Re: Porting from VC6 to VS2005
- From: AVee
- Porting from VC6 to VS2005
- Prev by Date: Re: Porting from VC6 to VS2005
- Next by Date: When Drawing the menu , How to remove the shadow of menu ?
- Previous by thread: Re: Porting from VC6 to VS2005
- Next by thread: Re: Porting from VC6 to VS2005
- Index(es):
Relevant Pages
|