lundi 29 juin 2015

Why is the expression a++ = 5 give an error during compilation? [on hold]


The given code is :

int a = 0;
a++ = 5;

My opinion from what I learned so far:

This will not work bacuse

a++ 

is not lvalue.

But what is lvalue ?

I think lvalue is the left variable,array index or a pointer which must have a location in memory.

since

a++

is an expression that not give an excat location in memory, it is not lvalue. Therefore this will not compiled correctly and will give an error. I'm not sure I understood it. Am I correct ? thanks.


Aucun commentaire:

Enregistrer un commentaire