A() = A() – why does it compile?

For built-in types, you’d be correct: the built-in assignment operator requires a modifiable lvalue on the left hand side.

However, this is not using the built-in operator, but the overload that’s implicitly declared by the class. This is a member function, equivalent to

A().operator=(A());

and member functions can be called on rvalues.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)