const int* 和 int const*的区别?
来源:互联网 发布:苹果笔记本装mac 编辑:程序博客网 时间:2024/05/22 02:30
Thinking in C++ 看到了第八章,讲的是指针。
这里提出这两个的区别是:
1、const int* 指向const的指针
对于这个的解释是:
const int* u; //u是一个指针, 它指向一个const int.这里不需要初始化,因为u可以是指向任意标识符(也就是说它不是一个const),但是它的值是不能被改变的。
2、int const*这个是指向int 的const指针
对于这个的解释是:
int * const w = &d;
现在读成w是一个指针, 这个指针是一个指向int的const指针。因为指针本身就是const指针,编译器要求给它赋一个初值,这个值再生名周期中内不变,然而改变它的
值是可以的。
#include <iostream>
using namespace std;
const int* u;
int const* v;
int d = 1;
int* const w = &d;
const int* const x = &d;
int const* const x2 = &d;
int main()
{
}
0 0
- const int* 和 int const*的区别?
- const int*和int const*的区别
- Const int *, int const *, 和int * const 的区别:
- int *const 和 int const*的区别 (指针 和 const)
- const int *x 和 int * const x, const int& x和 int const &x的区别
- const int & 和 int 的区别
- const int 和INT const区别
- const int *p 和 int* const p 的区别详解
- int const * pci和int * const cpi的区别
- const int * pt和int * const pt的区别
- int const * p1和 const int * p1的区别
- C++ const int* p 和 int * const p的区别
- 关于const int*, int const*以及int *const的区别
- const int * 与int const * 与int * const的区别
- 关于const int*, int const*以及int *const的区别
- const int *与int *const 的区别
- const int * p 和 int const * p 和 int * const p 的区别
- int *const p,const int *p和int const *p的区别
- 蓝牙设置应用源码分析
- 第13周上机实践项目5——字符串操作(1)
- [开篇]C#静态变量调用及初始化
- Unity study 141125-1
- [java 基础]Eclipse下发布的应用在Tomcat服务器下的关联
- const int* 和 int const*的区别?
- 直接拿来用!最火的iOS开源项目
- [LeetCode] Rotate List
- xcode 6 如何将 模拟器(simulator) for iphone/ipad 转变成 simulator for iphone
- 什么是数据填报,有什么特点
- NSUserDefaults的使用
- Mac系统下 修改mysql的最大连接数
- Hive 的 distribute by
- Android中SQLite的使用方法