C++ revisit
来源:互联网 发布:windows专业版和旗舰版 编辑:程序博客网 时间:2024/06/08 10:43
1,引用不能重新绑定,且引用不是对象,所以没有指向引用的指针
int a=1,b=2;int &c = a;int &c = b;//wrong
int a=1;int &b = a;int &*c = &b;//error: cannot declare pointer to 'int&'|
2,不能通过const 引用改变引用对象的值,但如果引用对象的值改变,const 引用的值也改变。
int a=1;const int &b = a;int &c = a;c = 2;cout<<a<<" "<<b<<" "<<c ;
3,指向常量的指针,和常量指针:
int a1=1,a2=2;const int *b = &a1;//指向常量的指针int *const c = &a1;//常量指针cout<<a1<<" "<<*b<<" "<<*c<<endl; //*b = 2;//wrongb = &a2;*c = a2;//c = &a2;//wrong 不能改变地址cout<<a1<<" "<<*b<<" "<<*c<<endl ;
4,指针相互赋值
int a=1,b=2,c=3,d=4;int *ptr1 = &a;const int *ptr2 = &b;int *const ptr3 = &c;const int* const ptr4 = &d;cout<<*ptr1<<" "<<*ptr2<<" "<<*ptr3<<" "<<*ptr4<<endl;
指针相互赋值时,底层指针可以相互赋值:
ptr2 = ptr4const int* const ptr5 = ptr2;
阅读全文
0 0
- GSO revisit
- C++ revisit
- C++ revisit
- revisit hotswap controller
- Revisit pass by value
- Hibernate Performance Revisit
- HDFS中的Append/Hflush/Read规范文档(HDFS-265:Revisit append / Append&Hflush&Read Specification)
- HDFS Append 设计文档的QA(HDFS-265:Revisit append/Questions about the "Append Design")
- Hadoop中HDFS文件系统的Append/Hflush/Read设计文档(HDFS-265:Revisit append)
- Hadoop中HDFS文件系统的Append/Hflush/Read设计文档(HDFS-265:Revisit append)
- Hadoop中HDFS文件系统的Append/Hflush/Read设计文档(HDFS-265:Revisit append)
- Hadoop中HDFS文件系统的Append/Hflush/Read设计文档(HDFS-265:Revisit append)
- Hadoop中HDFS文件系统的Append/Hflush/Read设计文档(HDFS-265:Revisit append)
- c
- c
- c
- c
- C
- 对数字图像的理解(一)
- Standard IO-----数字金字塔(CCF 1145)
- Python_uuid
- Hibernate--hibernate.cfg.xml说明
- Jetty 的工作原理以及与 Tomcat 的比较
- C++ revisit
- 172. Factorial Trailing Zeroes计算n!末尾0的个数
- python3 [爬虫入门实战]爬虫之selenium 安装设置与初步使用
- Nginx全局变量
- C# 连接数据库 以及数据库增删改查
- SpringMVC对静态资源的的处理
- jzoj4216. 【NOIP2015模拟9.12】平方和(splay+码量)
- 正则表达式
- Peewee中文文档【五】:贡献