Cpp-Primer icon indicating copy to clipboard operation
Cpp-Primer copied to clipboard

Ex 2.31 Wrong Answer

Open qdntang opened this issue 7 years ago • 3 comments

r1 = v2;

It should be illegal, since reference to "int" can not bind to value of type "const int".

qdntang avatar Feb 14 '18 04:02 qdntang

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.

miehmg avatar Jul 15 '18 00:07 miehmg

I was also confused about this.And now I totally agree with you.Thanks

Kyle-Ye avatar Jan 23 '19 16:01 Kyle-Ye

r1 = v2;

It should be illegal, since reference to "int" can not bind to value of type "const int".

我认为你把“初始化”和“赋值”操作弄混了,如果是初始化这是不合法的,但是这里是赋值操作

578223592 avatar Dec 21 '22 05:12 578223592