Fun surprising things

bauss jj_1337 at live.dk
Thu Nov 1 09:24:36 UTC 2018


On Thursday, 1 November 2018 at 04:39:17 UTC, Nick Sabalausky 
(Abscissa) wrote:
> On 10/31/18 10:00 AM, bauss wrote:
>> What's the output of this program? (Try to figure it out 
>> without running it.)
>> 
>> ```
>> int c = 0;
>> 
>> int a()
>> {
>>      return c++;
>> }
>> 
>> int b()
>> {
>>      return c--;
>> }
>
> I'm not sure I understand the point here. I mean, who writes 
> code like that? Pre/Post-incement operators? Combined with 
> globals? To me that just smells of trouble.
>

The point is not what the functions do, but the order of 
evaluation.

It was just a simple example to reproduce it.




More information about the Digitalmars-d mailing list