|
发表于 2004-4-4 12:03:35
|
显示全部楼层
"const int *pr" == "int const *pr"
but "const int *pr" != "int * const pr"
"const int *pr" means the object pointed by "pr" is a constant
example:
const int *pr=&i;
*pr=2; //error!!!
pr=NULL; //OK
"int * const pr" means the pointer "pr" is a constant
example:
int * const pr=&i;
*pr=2; //OK
pr=NULL; //error!!!
"const int * const pr" means both the object and the pointer are constants
const int * const pr=&i;
*pr=2; //error!!!
pr=NULL; //error!!! |
|