C++学习过程中的一些笔记
来源:互联网 发布:琅琊榜细节 知乎 编辑:程序博客网 时间:2024/06/05 18:28
书:C++ Primer 英文版 (以下英文部分为本人学习过程中的总结笔记,中文部分为编写博客时的注释。)
关于references的注意事项:
2.3.1 P50 References
References :
a references is an alias.
a reference can only bound to an object.
a reference must be initialized.
Define a reference : int ival = 1024;
int &refVal = ival;
Exercise 2.17
#include <iostream>
int main(int argc, const char * argv[]){
// insert code here...
int i, &ri = i;
i = 5;
ri = 10;
std::cout << i << " " << ri << std::endl;
return 0;
}
the result is 10 10.
it means that ri is an alias of i. 意味着ri是i的一个别名
关于使用指针
2.3.2 P52 Pointers
nt i = 10;
int *p = &i; // & is a address-of operator which is use to get the address of the object
std::cout << *p << std::endl;//in this line, * is a dereference operator for accessing the object to which the pointer points
指针保存一个对象的地址
A pointer stores the address of an object.
指针和引用的关键不同之处
The key difference between references and pointers is :1. a reference is not an object and it is always bound to the object which is its initializer ,which means that it can not refer to a different object,while a pointer is an object and can point to a different object by assignment.
0 0
- 修改page_alloc.c过程中的一些笔记
- 学习java过程中的一些笔记.
- C++学习过程中的一些笔记
- ssh框架学习过程中的一些小知识和笔记
- 学习 unity过程中的一些笔记和发现(1)
- 学习中的一些笔记
- 学习过程中的一些感悟
- 学习过程中的一些疑问
- 学习过程中的一些总结
- 学习过程中的一些细节
- linux C 学习中的一些小笔记,不断更新
- C/C++开发过程中的一些bug
- C语言开发过程中的一些积累
- php学习中的一些笔记.
- Oracle学习中的一些笔记
- JavaScript学习中的一些笔记
- STL学习过程中的笔记
- 学习HTML过程中的笔记
- 《深入浅出 Java Concurrency》—锁机制(十) 锁的一些其它问题
- 写Makefile
- 如何鉴别snidel真假
- SharePoint 中调用传出电子邮件中的邮件服务器及地址发送邮件
- 字符串与正则表达式
- C++学习过程中的一些笔记
- ActiveX控件中加载BCB编写的dll的注意事项
- 第四周作业——图的表示
- ios Sqlite数据库增删改查基本操作
- 发送TCP数据包
- 搜狐云景客户端工具评测之WordPress的搭建
- google开源protobuf
- vc中release和debug的区别
- JAVA 通过HtmlParser获取指定的tag