that would have been a trick question and the answer is as you expected when you use 
the correct slash...

-----Original Message-----
From: Kevin OKeefe 
Sent: Tuesday, June 24, 2003 12:45 PM
To: Palm Developer Forum
Subject: RE: offtopic: who can figure out this for loop


this slash '\' is continuation not '/'...



-----Original Message-----
From: Sebastian Voges [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 24, 2003 12:43 PM
To: Palm Developer Forum
Subject: RE: offtopic: who can figure out this for loop


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/


------------------------------------------
The information in this transmittal and any attachments are confidential and intended 
only for the recipient(s) listed above. You are hereby notified that any unauthorized 
distribution or copying of this transmittal or its attachments is prohibited. If you 
have received this transmittal in error, please notify invivodata immediately at (831) 
438-9550.
------------------------------------------



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



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

Reply via email to