const Pointers and Pointer to const Objects 常量指针和指向常量对象的指针
来源:互联网 发布:企业数据意识改进 编辑:程序博客网 时间:2024/05/20 04:27
//英文来源:C++ Primer, 4th edition
//Part of the problem in reading const declarations arises because the 'const' can go either before or after the type.
//为什么有const的代码阅读起来会比较困难呢?因为const可以出现在类型的前面或后面。
{
char ch='a';
char* const P1=&ch;//指针本身是常量。
//As with any 'const', we must initialize a 'const' pointer when we create it.
//正如任何常量一样,常量指针必须初始化。
//指针指向的内容是常量。以下2句是等价的。
const char *P3;
char const *P4;
P3=&ch;
*P3='b';//错误的!
//Although 'ch' is not a 'const', any attempt to modify its value through P3 results in a compile-time error.
//无论P3指向的内容是否常量,都不能通过P3修改其指向的内容。即*P3=...是错的。
}
0 0
- const Pointers and Pointer to const Objects 常量指针和指向常量对象的指针
- 常量指针(const pointer)和指向常量的指针(pointer to const)
- const常量、指向常量的指针和常量指针
- const常量、指向常量的指针和常量指针
- const常量、指向常量的指针和常量指针
- const常量、指向常量的指针和常量指针
- const常量、指向常量的指针和常量指针
- Item07. 常量与指针的联姻(Const Pointers and Pointers to Const)
- 常量指针 const void * 指针常量 void* const 指向常量的指针常量 const void* const
- const->形式参数、指向常量数据的指针、指针常量
- const修饰指针的用法:常量指针和指针常量
- 指针和const的联系---常量指针与指针常量
- 常指针和指向常量的指针 const int *p;int * const p ;const int * const p
- 常量指针和指针常量(const)
- c++常量指针和指针常量--const
- const int *p和int * const p的区别(常量指针与指向常量的指针)
- const int *p和int * const p的区别(常量指针与指向常量的指针)
- const int *p和int * const p的区别(常量指针与指向常量的指针)
- 设置Hadoop用户以便访问任何HDFS文件
- poj 1159 dp Palindrome
- 事件分发与消费(初学)
- 智能机器人设计
- Longest Substring Without Repeating Characters
- const Pointers and Pointer to const Objects 常量指针和指向常量对象的指针
- hdu 1576 A/B 扩展欧几里得算法
- udev分析
- 《鬼泣》连招攻击动作分析总结
- var_var.php
- eclipse开发安卓时logcat的绿色加号不见了
- HiveQL学习笔记
- 3月24日学习笔记
- 案例分析:个人所得税计算办法