Temporaries cannot be bound to non-constant references means when
int &z = 12; //this is wrong here 12 is temporary.
a temporary object of type int
is created from the integral literal 12
, but the temporary cannot be bound to non-const reference. Hence the error.
int y;
int &r = y;//but this is correct
In 1st expression p += a(b(p)) , directly calling b function means we are assigning value of object type.but in 2nd and 3rd expression, we are passing temporary values i.e q+= b(a(q));// first b function calls,then m becomes 3,and that 3(temporary value) we r assigning to b function parameter that is not valid.same in the case of 3. so option A (compile error)
Temporaries only be bound to constant references
const int &z = 12;