In this code:
int a=8;
const int &b = a; //b is a Low-Level const
auto c = b;
I expected c
to be constant reference type since it has been auto
ed to a low level const. But instead it is referring to a
(which has been aliased by b
) instead if b
for its declaration.
c
picks the b
's type only when it is used like auto &c =b
What I understand is only top-level const is dropped. So can someone please explain what is wrong with my understanding?
.
Aucun commentaire:
Enregistrer un commentaire