the difference between const int *, int * const, int const *
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 *的更多相关文章
- const int * p 和 int const * p 和 int * const p 的区别
首先注意,const int * p 和int const *p 是一样的,并且不管是不是*p,即使const int i和int const i也是一样的,所以我们接下来只讨论int const * ...
- const int *p与int *const p的区别(转:csdn,suer0101)
本文只是一篇学习笔记,是看了<彻底搞定C指针>中的相关篇幅后的一点总结,仅此而已! 一.先搞清const int *p与int const *p的区别 它们的区别就是:没有区别!! 无论谁 ...
- C++ char*,const char*,string,int 的相互转换
C++ char*,const char*,string,int 的相互转换 1. string转const char* string s ="abc";const char* ...
- const int *p 和int * const p 的区别
看例子: int sloth = 3; const int *p1 = &sloth; int * p2 const = &sloth; 这样申明的话,不允许使用p1来修改sloth的 ...
- (c++) int 转 string,char*,const char*和string的相互转换
一.int 和string的相互转换 1 int 转化为 string c++ //char *itoa( int value, char *string,int radix); // 原型说明: / ...
- 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);* ...
- [转] const int *a与int *const a,const int *const a的区别
http://blog.csdn.net/zhangheng837964767/article/details/33783511 关键问题点:const 属于修饰符 ,关键是看const 修饰的位置在 ...
- const int *a与int *const a,const int *const a的区别
来源:https://blog.csdn.net/zhangheng837964767/article/details/33783511 关键问题点:const 属于修饰符 ,关键是看const 修饰 ...
- what is difference in (int)a,(int&)a,&a,int(&a) ?
This interview question come from a famous communication firm of china. : ) #include <iostream> ...
- C++中 int i 与 int &i 注意事项
来源:http://blog.csdn.net/qianchenglenger/article/details/16949689 1.int i 传值,int & i 传引用 int i不会回 ...
随机推荐
- ios 真机调试 could not find Developer Disk Image
同事不小心把iphone测试机升级到了最新系统, 真机调试以前的项目时候不能运行, 提示could not find Developer Disk Image. 原因:缺少最新系统9.3的镜像 解决办 ...
- linux查看系统命令
[root@server ~] # uname –a # 查看内核/操作系统/CPU信息的linux系统信息命令 [root@server ~] # hea ...
- mysql 操作杂记
SHOW VARIABLES LIKE 'character%'; SET character_set_client = utf8; SET character_set_connection = ut ...
- sql语句查询最近七天 三十天 数据
几个小时内的数据 DATE_SUB(NOW(), INTERVAL 5 HOUR) 今天 select * from 表名 where to_days(时间字段名) = to_days(now()); ...
- 【zz】matlab 腐蚀膨胀算法
1.图像膨胀的Matlab实现: 可以使用imdilate函数进行图像膨胀,imdilate函数需要两个基本输入参数,即待处理的输入图像和结构元素对象.结构元素对象可以是strel函数返回的对象,也可 ...
- loadrunner四大部分
loadrunner主要分一下四部分 1.VuGen 主要进行录制,回放,参数化,脚本修改,可以对脚本进行recording options,General options,runtime opti ...
- sqlserverdriver配置方法 jdbc连接sqlserver
一.下载驱动程序. 下载地址:http://download.microsoft.com/download/8/B/D/8BDABAE2-B6EA-41D4-B903-7916EF3690EF/sql ...
- Python学习路程day15
Python之路[第十五篇]:Web框架 Web框架本质 众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端. #!/usr/bin/en ...
- Android Full Screen
http://talentprince.github.io/blog/2015/01/07/android-activity-quan-ping-fang-fa-zong-jie/
- 区分苹果Safari浏览器
区分苹果Safari浏览器 (function() { var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; (s = ua ...