c ++ 11中的自动引用 [英] auto reference in c++11
本文介绍了c ++ 11中的自动引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在about
自动引用时遇到了麻烦.
I have some trouble about
auto reference.
const int i = 1;
auto & ri1 = i;
auto & ri2 = 1; //error
为什么推导出ri1
const int
而不是ri2
类型?
Why is deduced type of ri1
const int
but not ri2
?
谢谢!
推荐答案
由于i
具有类型const int
,而1
具有类型int
.
Since i
has type const int
, but 1
has type int
.
这篇关于c ++ 11中的自动引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文