struct myStruct
{
int age;
char name[20];
};
void fun1(const myStruct *p)
{
//p->age = 10; 编译不通过.指针所指向的内存空间不能被修改
}
void fun2(myStruct* const p)
{
p->age = 10;
//p = nullptr; 编译不通过.指针变了本身不能被修改
}
void fun3(const myStruct* const p)
{
//只能打印或者输出. 指针本身,和指针指向的内存空间都不能被修改
}
原文:http://www.cnblogs.com/mayichen0823/p/6683270.html