Study notes in the second week in GeekBand
来源:互联网 发布:eclipse修改端口号 编辑:程序博客网 时间:2024/04/29 13:04
拷贝构造string s3(s2);
拷贝赋值(=);
构造函数
析构函数
字符串结束标示符号\0,申请空间时需要注意
new分配内存空间,delete释放空间,配对使用
浅拷贝(编译器默认传指针)(会造成memory leak,别名alias,两个指针指向同一块内存空间不安全),深拷贝(拷贝构造函数)
检测自我赋值,(原先二者指向同一处)
STACK,HEAP,static
谁调用,谁就是this
内存块,16的倍数;16进制末尾1标示
static function(没有this pointer)处理static data
类模板
namaspace(using directive\using declaration)
类与类之间的关系——继承、复合、委托
复合(Composition),has-a,Adapter(改造适配)
复合关系下的构造函数和析构
构造,由内而外
Container( Component)
Container::Container(...):Component(...){...}; //Component构造首先执行
析构,由外而内
Container::~Container(...){...~Componet()}; //先外层析构,
委托(Delegation)——Compositon by Reference
用到时才创建,生命创建时间/周期不一样
pImpl(pointer to Impletation)Handle/Body,编译防火墙,reference counting(共享)
继承(Inheritance),表示is-a
Derived::Derived(...):Base(...){...}; //先调用基类构造
Derived::~Derived(...){...~Base(...)};
base class的析构函数必须是virtual,否则会出现undefined behavior,当你new申请派生类对象然后释放时,实际释放的是基类的对象,而不是你认为的派生类,虚析构函数就可以先释放派生类对象,再释放基类对象
non-virtual函数,不希望子类重新定义(override)
virtual 函数,希望子类重新定义,已有默认定义
pure virtual函数,希望子类一定要重新定义,并且没有默认定义
继承+复合关系下的构造(2种方式)
继承+委托
Shape<--Rectangle(Point),构造函数执行顺序:先基类Shape,再Point,后Rectangle,;析构顺序:先Point,在Rectangle,后Shape
0 0
- Study notes in the second week in GeekBand
- Study notes in the first week in GeekBand
- in Mar. 2007 ,my work and study plan at the second week
- The second week in my university
- Geekband-second week笔记
- Second Week In Moto GSG
- 《programming in scala》study notes
- the second in Japan
- The Second--Static in java
- The First Week In Augmentum
- The Second Week!
- The stack in assembler (notes)
- Spring - the way in the study
- Life in America for the first week
- study notes for EJB 3 in action (I)
- study notes for EJB 3 in action (II)
- study notes for EJB 3 in action (III)
- The study of loop in Python(20170906)
- 什么是中间件,nodejs的概念
- java注解
- Silex:Doctrine的使用
- JSP的几个小结
- mac系统上使用压缩包版的mysql(非安装版)
- Study notes in the second week in GeekBand
- BLE 广播数据解析
- Object类,接口类与抽象类
- 字节排序函数
- 理解SQL原理,写出高效的SQL语句
- 贴点国外大神代码,没事瞅瞅
- 【二分+几何】F - Expanding Rods
- 字符串匹配算法
- HDU 5754 Life Winner Bo(博弈)