Since in C++ forbidden to reassign the link.
int &a = some_int; a = some_other_int; // value copied not reference a = some_int; // value copied not reference
When you use the assignment operator (generated by the compiler), it blindly copies objects and thus tries to reassign your reference and is therefore invalid.
When you say a2 = a1; , the compiler will try to reassign a1.r to a2.r , which will lead to a compile-time failure, because this is bad behavior.
You can imagine the link as automatically dereferenced constant pointer . Thus, the string a2 = a1; will remain poorly formatted for the same reason as for the class below.
struct A { A(int *var) : p(var) {} int * const p; };
source share