Tuesday, February 26, 2008

FAQ

Question 1
Postfix and prefix increment operator priority issue.

Answer
Postfix increment / decrement operators have MORE priority than prefix increment / decrement operators.

Postfix increment / Decrement operator : Associativity -> Left to Right
Prefix increment / Decrement operator : Associativity -> Right to Left

*********************************************************************************
Question 2
Pointer Subtraction

Answer

* Pointer subtraction (address subtraction) gives the "distance" between two objects.

* These Two objects must be of same type (two objects can be of different base type but in this case their diff makes little sense.)

* The operation is signed Arithmetic

* Depending on the languages and its Implementation, The result is "negative" if the first operand is stored at lower address than the second operand (at higher address.)

*********************************************************************************