assigning char to int reference and const int reference in C++
问题 I noticed that assigning a char to a const int& compiles, but assigning it to a int& gives a compilation error. char c; int& x = c; // this fails to compile const int& y = c; // this is ok I understand that it is not a good practice to do this, but I am curious to know the reason why it happens. I have searched for an answer by looking for "assigning to reference of different type", "assigning char to a int reference", and "difference between const reference and non-const reference", and came