mercredi 6 mai 2015

C: Error in Using: "Compound Assignment" and "Prefix Decrement" together

Can someone please tell me why the C compiler outputs an error while using a Compound Assignment and a Prefix Dec/Inc together ? [ but C++ does not ]

int myVar = 5;
(--myVar) -= 4;
// C  : error C2106: '-=' : left operand must be l-value
// C++: myVar=0;

I know what the error says ...

But, I can't understand why a C compiler can't recognize myVar as a l-value but C++ does?!

Aucun commentaire:

Enregistrer un commentaire