const关键字

1》修饰基本类型变量(使其只读)

 

2》修饰指针:

  ①、int const *p或者const int *p;

    *p是只读的,不可以通过指针修改,可以通过变量修改;

  ②、int * const p;

    const将p变为只读数据

  ③、const int * const p;

     const将p和*p都变为只读数据

posted @ 2017-07-24 08:41  hello,123456  阅读(105)  评论(0编辑  收藏  举报