One code, 2 different results C# vs C++

Discussion in 'MCSD' started by Shailendra Sharma, Jun 29, 2003.

  1. The difference lies in handling of extended assignment
    operators such as +=, -=, /= etc etc in different
    languages such as Java or C# versus C++.
    In Java it is handled like this...
    <variable><op>=<expression> the symantics for this are
    <variable> = (<type>)(<variable><op>(<expression>))
    Note, in Java the <variable> is evaluated just once upon
    entry v/s C++ where the latest values for the variable is
    used, hence the difference. Please refer to "Programmers
    Guide to Java Certification by Khalid Mughal, page 53" for
    reading up on Java's handling of Extended Assignment
    operators. I do not think it is operator precedence.
    Extended assignment operators have same precedence as
    assignment operators which is the lowest in the precedence
    table, --, ++ are ranked much much higher than assigment
    operators....
     
    Shailendra Sharma, Jun 29, 2003
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.