What's the point of const pointers?

后端 未结 17 1917
粉色の甜心
粉色の甜心 2020-11-30 17:28

I\'m not talking about pointers to const values, but const pointers themselves.

I\'m learning C and C++ beyond the very basic stuff and just until today I realized t

17条回答
  •  我在风中等你
    2020-11-30 17:36

    Your question is really more about why define any variable as a const not just const pointer parameter to a function. The same rules apply here as when you define any variable as constant, if its a parameter to function or member variable or a local variable.

    In your particular case, functionally it doesn't make difference like in many other cases when you declare a local variable as const but it does put a restriction that you can't modify this variable.

提交回复
热议问题