c++ const

1、顶层const     //变量本身不可变。该内存地址中的值不允许再改变!

  int const a = 20;

  int *const pA = &a; //这个指针不能再指向其他变量

2、底层const     //不能通过该途径(变量、变量地址)改变指向对象

  const int* pA = &a;

  多用于传参void test(const int *pInt)

posted @ 2018-05-30 11:30  -南  阅读(79)  评论(0编辑  收藏  举报