c++11 - C++: Confusion on auto deduction using a const against an array -


example code:

int aa[] = {1,2,3,4}; auto const p = aa; 

why p deduced int *const instead int const *?

because aa non-const array, decay pointer-to-non-const , therefore p deduced pointer-to-non-const. , because declared p const, const pointer-to-non-const.

declaring variable const make variable const. doesn't make type of variable different (pointer-to-const , pointer-to-non-const different types) except in sense may const qualified version of same type.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -