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不会回 ...
随机推荐
- C++数据类型和变量类型。
数据类型 数字是自由的[不只属于某个类型]!但是它可以有不同的身份!int.char.float.double等身份.它以不同的身份[存储规则]存储在内存的某个位置内部! 变量类型 内存编号是不会变的 ...
- 利用CSOM向列表添加文件夹
博客地址:http://blog.csdn.net/FoxDave 本文只为记录一下这个小细节,不会过多赘述,开发可以看懂. 如果想向一个列表或库中添加文件夹,平时我们自然想到的是list.ro ...
- Unity中游戏的声音管理
using UnityEngine;using System.Collections;using System.Collections.Generic;/// <summary>/// 用 ...
- (转)Apache实现反向代理负载均衡
说到负载均衡LVS这套技术,有很多种实现方法. 本文所说,主要就是利用apache服务器实现反向代理,实现负载均衡. 首先,传统的正向代理如下图所示,正如我们用的游戏加速代理,大多的个人PC把请求发给 ...
- iOS应用性能调优好文mark
http://www.cocoachina.com/ios/20150408/11501.html
- BackTrack5-r3任务栏显示网络图标及自定义DNS
任务栏显示网络连接图标:安装NM工具,在BT终端中执行:apt-get install network-manager按y继续执行,显示:ldconfig deferred processing no ...
- LayaAir引擎——(六)
LayaAir引擎——TiledMap地图图块属性获取和进行墙壁碰撞检测 需要的软件: TiledMap LayaAir IDE 1.0.2版本 所画的地图: pass层: floor层: pass层 ...
- SlickUpload 发布到IIS后报错
开发时候采用slickupload控件都没问题,项目发布到IIS时发生了错误: Could not contact SlickUpload request progress handler at /S ...
- c#中方法的重载
转自:http://www.cnblogs.com/lovesong_blog/articles/1416617.html string和program都是Object的派生类,string类型是se ...
- Mongodb在Linux下安装及配置
1.下载mongodb的linux版本(注意32位和64位的区别),下载地址:http://www.mongodb.org/downloads 2.将下载的mongodb安装文件mongodb-lin ...