C++標準規(guī)定,const關(guān)鍵字放在類型或變量名之前等價的。
const int n=5; //same as below
int const m=10
const char * pstr; // pstr 是字符指針,它指向的量是 const的,
例如: char *m= "hello world 1";
char *n= "Hello world 2";
const char * pstr=m;
pstr[1]= 'H '; // it 's wrong
pstr=n; // it 's right
char* const pstr;// pstr 是字符指針,這個指針的值必須初始化,初始化以后就不能改變了.
例如: char *m= "hello world 3";
char *n= "Hello world 4";
char* const pstr=m;
pstr=n; // it 's wrong
pstr[1]= 'H '; // it 's right
至于 const char* const pstr 自然是兩者的結(jié)合了.