why can't it declare as
typedef int& A;
const A a = 3;
which throws
cannot bind non-const lvalue reference of type 'A' {aka 'int&'} to an rvalue of type 'int'
Does it have any difference between
const int& a = 3;
why can't it declare as
typedef int& A;
const A a = 3;
which throws
cannot bind non-const lvalue reference of type 'A' {aka 'int&'} to an rvalue of type 'int'
Does it have any difference between
const int& a = 3;
Does it have any difference between
const int& a = 3;
Yes. Given const A, const is qualified on A itself; A is a reference as int &, and the reference itself can't be const-qualified, the const qualifier is just ignored. As the effect, const A is same as int& (but not const int&), and int& a = 3; is ill-formed as the error message said.