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. google closure继承模块三:goog.base()源码分析

    直接看代码吧: base: function (me, opt_methodName, var_args) { var caller = arguments.callee.caller; if (ca ...

  2. DateTimePicker如何与Delphi自带Style同步

    Delphi 的 DateTimePicker 组件有一个CalColors属性,可以设置 DropDown 打开的日历节目的风格.但如果不使用 Delphi 自带的 Style,在这里设置属性看不到 ...

  3. EXCEL 图表 只在拐点的时候显示数字

    EXCEL图表只在折线的拐点显示数值,中间不需要显示.同时往下拐的,显示在上方,往上的显示在下方,这样数值不会挡住线. 首先,做一些模拟数据 因为起点和终点数值必须显示,所以单元格,C2 D2 C19 ...

  4. javascript 在ie8中报“缺少标识符、字符串或数字“问题再现:

    开发和测试使用Chrome浏览器比较多,客户反馈某个页面打不开,自己用Chrome打开一切正常,用ie8打开,果然页面展现卡在那儿了,并且报了"缺少标识符.字符串或数字".查看是在 ...

  5. 移动混合开发之android文件管理-->flexbox,webFont。

    增加操作栏,使用felxbox居中,felx相关参考网址:http://www.ruanyifeng.com/blog/2015/07/flex-grammar.html 使用webFont添加图标, ...

  6. DOM扩展之 专有扩展

    11.4.3 contains() 方法 用来确定某个节点是不是另一个节点的后代. 注:a.contains(a) 也是返回true.说明contains方法搜索是从自身开始的. DOM Level ...

  7. [SHELL]判断一个命令是否存在

    首先要说明的是,不要使用which来进行判断,理由如下: 1.which非SHELL的内置命令,用起来比内置命令的开销大,并且非内置命令会依赖平台的实现,不同平台的实现可能不同. # type typ ...

  8. hdu 2066

    ps:我天...之前看了迪杰斯特拉..现在这题要用到floyd..就是先建一个图,然后从列开始遍历,每列里遍历行,行又对应每列... 从A列开始遍历每行,比如遍历到B,这时候B->A知道是2,接 ...

  9. 入住cnblogs第一篇随笔 Hello, world!

    在网上搜索计算机参考资料时经常看到各位大神的博客,甚是神往.今天我也在这里安家,记录自己的学习过程,也同各位共勉. 第一篇随笔,就用来测试一下这里的文本编辑器吧. //The C language # ...

  10. SRS文档

    1什么是用例? 在介始用例方法之前,我们首先来看一下传统的需求表述方式-"软件需求规约"(Software Requirement Specification).传统的软件需求规约 ...