//error: invalid initialization of reference of type 'int&' from expression of type 'double'
//int &refb1 = b;
const int &refb2 = b;
谢谢。
...全文
1316打赏收藏
问一下const引用和普通引用的区别
问一下为什么,普通引用只能绑定到和自己一样的类型,const引用却可以绑定到和自己相关的类型,即绑定范围更大了。 double b = 100.1; //error: invalid initialization of reference of type 'int&' from expression of type 'double' //int &refb1 = b; const int &refb2 = b; 谢谢。