指针

void reset(int *p)
  {
  *p=0; //changes the value of the object to which ip points这样子会把实参的值改掉
   p=0; //changes only the local value of ip; the argument is unchanged这样实参值不会修改
  }

如果需要保护*p指针,则其定义为const类型。

如: void reset(const int *p){

……

}

当形参定义为const类型时,可以通过传递字面值直接进行参数传递

一般情况下,当函数无需修改该实参指针的值时,可以定义为const类型,以对指针进行保护。。。如果使用引用形参的唯一目的是避免复制实参,则应将形参定义为const引用