指針指向const修飾的變量時(shí),int const a=3;const int const*p=&a和const int *p=&a有啥區(qū)別,后者對(duì)嗎
指針指向const修飾的變量時(shí),int const a=3;const int const*p=&a和const int *p=&a有啥區(qū)別,后者對(duì)嗎
指針指向const修飾的變量時(shí),int const a=3;const int const*p=&a和const int *p=&a有啥區(qū)別,后者對(duì)嗎
2015-11-12
舉報(bào)
2015-11-12
const int const *p = &a; // *p 和 p均為常量
const int *p = &a; // *p 為常量 ,p是變量(可以指向其它地址)
2017-02-22
應(yīng)該寫成const int* const p = &a; 嗎
2015-11-12
const int const*p 這種寫法編譯器會(huì)報(bào)錯(cuò)的! 兩個(gè)const都是修飾int的,重復(fù)了。
const int *p 和 int const *p 這兩種寫法是一樣的,都是將p聲明為指向const int的指針。