0

Constant reference can be changed?

Hello Output of below code is 1111 , but I was expecting compile error : int a =10; int const &b = a; a = 11; cout << a << b; If we refer second line, b is constant and it is just an alliance of variable a... now, third line is trying to change value of a (inturn variable b). how come value is printed instead of compile error.

31st May 2018, 9:37 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 ответ