Cpp-Primer
Cpp-Primer copied to clipboard
Ex 2.31 Wrong Answer
r1 = v2;
It should be illegal, since reference to "int" can not bind to value of type "const int".
nope, the r1 is already initialized to bind to an int, say v1. r1 = v2 means the same as v1 = v2; assign the value of constant int to int is legal. it does not mean bind r1 to v2, as r1 should be binded when initialization.
I was also confused about this.And now I totally agree with you.Thanks
r1 = v2;
It should be illegal, since reference to "int" can not bind to value of type "const int".
我认为你把“初始化”和“赋值”操作弄混了,如果是初始化这是不合法的,但是这里是赋值操作