Hi Kevin, Aaron,

allright i did not research that too well. codewarrior actually behaves
differently than the compilers i tried that.
that was supposed to be a fun question, but I think I blew it by not
testing it on codewarrior. 
here the thing:
>   int x = 1;
>   for( int i = 0; i < 100; ++i );
>     // What will the next line do? Increment???????????/
>     ++x;

on a standards conforming c++ compiler the ++x; line should be considered as a
comment because the previous line ends with a slash ( indicating that the
next line is a continuation of the previous line. since this line is a
comment the ++x; line should be considered as a comment as well and not be
compiled at all.
I verified this behaviour on two compilers

the semicolon in the for-loop was just meant for confusion.

oh well, this did not work out that well, i hope it is still worthwhile
technical content :-)

Sebastian

On Tue, 24 Jun 2003 15:36:01 -0400, Kevin OKeefe wrote:

> 
> The semi at the end of the for loop makes it an empty loop, the formatting of the 
> ++x is irrelevant, the answer is 2.
> 
> -----Original Message-----
> From: Sebastian Voges [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, June 24, 2003 12:30 PM
> To: Palm Developer Forum
> Subject: RE: offtopic: who can figure out this for loop
> 
> 
> 
>> 
>> 2
>> 
> close :-))
> Look at the code carefully. Did I mention it is a trick question?


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to