Some people may be confused about the sequence of const and * on declaration in C++/C, me too.

  Now I think we can distinguish them by this way:

  1.only noticing the position of const to *, and we can find that the following statements are same:    

const int * foo_int;
int const * foo_int_;  //same.

  2.regarding const as a postpositive attributes,and you will know the content which is const.

  

int foo = ;
int foo_ = ; //the foo_int is const, but the pointer to foo_int can be chaged.
int const * foo_int = &foo; //illegal, the value cannot be chaged
//*foo_int = 7 //okay!
foo_int = &foo_; //the pointer to int is const, but foo_int_ can be chaged.
int * const foo_int_ = &foo_int; //illegal, the pointer cannot be changed.
//foo_int = &foo_int_;
//even if the new pointer is same, it's illegal
//foo_int = &foo_int; //okay
*foo_int = ;

the difference between const int *, int * const, int const *的更多相关文章

  1. const int * p 和 int const * p 和 int * const p 的区别

    首先注意,const int * p 和int const *p 是一样的,并且不管是不是*p,即使const int i和int const i也是一样的,所以我们接下来只讨论int const * ...

  2. const int *p与int *const p的区别(转:csdn,suer0101)

    本文只是一篇学习笔记,是看了<彻底搞定C指针>中的相关篇幅后的一点总结,仅此而已! 一.先搞清const int *p与int const *p的区别 它们的区别就是:没有区别!! 无论谁 ...

  3. C++ char*,const char*,string,int 的相互转换

    C++ char*,const char*,string,int 的相互转换   1. string转const char* string s ="abc";const char* ...

  4. const int *p 和int * const p 的区别

    看例子: int sloth = 3; const int *p1 = &sloth; int * p2 const = &sloth; 这样申明的话,不允许使用p1来修改sloth的 ...

  5. (c++) int 转 string,char*,const char*和string的相互转换

    一.int 和string的相互转换 1 int 转化为 string c++ //char *itoa( int value, char *string,int radix); // 原型说明: / ...

  6. error C2556: 'const char &MyString::operator [](int)' : overloaded function differs only by return type from 'char &MyString::operator [](int)'

    char & operator[](int i);const char & operator[](int i);/*const char & operator(int i);* ...

  7. [转] const int *a与int *const a,const int *const a的区别

    http://blog.csdn.net/zhangheng837964767/article/details/33783511 关键问题点:const 属于修饰符 ,关键是看const 修饰的位置在 ...

  8. const int *a与int *const a,const int *const a的区别

    来源:https://blog.csdn.net/zhangheng837964767/article/details/33783511 关键问题点:const 属于修饰符 ,关键是看const 修饰 ...

  9. what is difference in (int)a,(int&)a,&a,int(&a) ?

    This interview question come from a famous communication firm of china. : ) #include <iostream> ...

  10. C++中 int i 与 int &i 注意事项

    来源:http://blog.csdn.net/qianchenglenger/article/details/16949689 1.int i 传值,int & i 传引用 int i不会回 ...

随机推荐

  1. mac 下配置tomcat

    下面就是一些简单的步骤,帮你把Tomcat7安装在你的Mac上. 下载一个 二进制包: apache-tomcat-7.0.27.tar.gz ,可以在Apache的官方网站找到. 双击解压在你的下载 ...

  2. ObjC宏定义-预编译小功能

    以前看来#号,好像只是预编译,原来它还可以有跟Swift中"\( )"的拼接功能 例如: #define string(x) #x 意思就是 string(x) = "x ...

  3. Webdriver设置Chrome属性

    1. ChromeDriver加载插件 File file = new File ("files\\youtube.crx"); ChromeOptions options = n ...

  4. 面试题12:打印1到最大的n位数

    // 面试题12_打印1到最大的n位数.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> ...

  5. NPOI 数据导入导出

    { //数据导入 OpenFileDialog open = new OpenFileDialog(); open.Filter = "Excle文件|*.xls"; open.T ...

  6. python调用NLPIR - ICTCLAS2013实现中文分词

    环境:win7.VS2008.Python2.7.3 第一步:照着文档[2]将NLPIR库封装成Python的扩展: 第二步:新建一个名为“nlpir_demo”的目录,将第一步最后得到的名为“nlp ...

  7. 初接触BurpLoader工具

    初接触burp工具 菜鸟一枚,现在在接触一段时间测试,我在测试功能性的时候,想着网站被黑案例那么多,我是不是也应该弄弄安全性测试了,所以就有了下边的第一次接触BurpLoader工具来测试手机的app ...

  8. ResultSet 结果集带回来的一些信息

    ResultSet.getMetaData() 得到结果集的结构信息,比如字段数.字段名等. ResultSet.getMetaData().getTableName(1) 就可以返回表名. Resu ...

  9. JXL操作Excel

    jxl是一个韩国人写的java操作excel的工具, 在开源世界中,有两套比较有影响的API可 供使用,一个是POI,一个是jExcelAPI.其中功能相对POI比较弱一点.但jExcelAPI对中文 ...

  10. 初学SQL常用到的一些指令

    一.库 查看有哪些库:show databases; 进入某个库:use 库名; 新增库:create database atm; (atm为库名) 删除库:drop database if exis ...