7 reference、const、new/delete
7.1 reference
x
是整数,占4字节;p
是指针占4字节(32位);`r` 代表`x`,那么`r`也是整数,占4字节
int x = 0;
int* p = &x; // 地址和指针是互通的
int& r = x; // 引用是代表x
4 specialization 特化
4.1 全特化 full specialization
模板是泛化,特化是泛化的反面,可以针对不同的类型,来设计不同的东西
- 其语法为
template<>
struct xxx<type>
2 xxx-like classes
2.1 pointer-like classes
2.1.1 智能指针
- 设计得像指针class,能有更多的功能,包着一个普通指针
- 指针允许的动作,这个类也要有,其中
*
,->
一般都要重载
共计 51 篇文章,7 页。