Reputation: 81
I have some trouble about auto reference.
about
const int i = 1; auto & ri1 = i; auto & ri2 = 1; //error
Why is deduced type of ri1 const int but not ri2?
ri1
const int
ri2
Thanks!
Upvotes: 3
Views: 349
Reputation: 33671
Since i has type const int, but 1 has type int.
i
1
int
Upvotes: 2