Squall Leonhart
Squall Leonhart

Reputation: 81

auto reference in c++11

I have some trouble about auto reference.

const int i = 1;
auto & ri1 = i; 
auto & ri2 = 1; //error

Why is deduced type of ri1 const int but not ri2?

Thanks!

Upvotes: 3

Views: 349

Answers (1)

awesoon
awesoon

Reputation: 33671

Since i has type const int, but 1 has type int.

Upvotes: 2

Related Questions