g++ gives error : invalid initialization of reference of type ‘char&’ from expression of type ‘unsigned char’
问题 when I try to compile the following code int main() { unsigned char uc; char & rc = uc; } g++ gives the following error : invalid initialization of reference of type ‘char&’ from expression of type ‘unsigned char’. The same happens when using signed char instead of unsigned char. But the following compiles well int main() { unsigned char uc; const char & rc = uc; } Why isn't it possible to initialize 'char &' with a variable of type 'unsigned char' while it is possible to initialize 'const