Effective C++——Study Notes
来源:互联网 发布:vb object转换 编辑:程序博客网 时间:2024/06/06 14:02
1.p3 区分声明declaration和定义definition,定义式是编译器为对象拨发内存的地点。区分定义和初始化,初始化是给予对象初值的过程。默认构造函数要不没有参数,要不所有参数都有缺省值。
2.p5 explicit关键字用来阻止构造函数执行隐式类型转换,但它们仍然可进行显示类型转换。比如int(38.0)
class B{public:explict B(int x=0;bool b=true);~B();}void foo(B bObj);foo(B(28.0)); //correctfoo(28); //wrong,foo接受的是B类型而不是int类型
3. p6 copy constructor以及copy assignment区分赋值操作符与复制构造函数。
class Widget{Widget();Widge(const Widge& rhs);Widget& operator=(const Widget& rhs);~Widge();}Widget w1; //default constructorWidget w2(w1); //copy constructorWidget w3 = w2; //copy constructor 而不是copy assignmentw2=w3; //copy assignment如果一个新对象被定义,一定会有个构造函数被调用,不可能调用赋值操作,如果没有新对象被定义,就不会有构造函数被调用,当然就是赋值操作符被调用。
4.STL,标准模板库是C++标准程序库的一部分,致力于容器,迭代器,算法及相关机能。许多相关机能以函数对象(function object)实现,那是“行为像函数”的对象。这样的对象来自于重载operator()(function call操作符)的class。回顾function object是经类实例化的对象,使用类封装函数功能。
5.不明确行为,undefined behavior。比如下面的两个例子。
int *p=0; //p是空指针
std::cout<<*p; //会导致不明确行为
char name[]="Darla"; //name是个数组,大小是6
char c=name[10]; //导致不明确行为
6.C++中的interface是指class的可访问元素或者函数的签名即函数原型。回顾interface inheritance和implementation inheritance,前者指派生类仅仅继承类的接口。
0 0
- Effective C++——Study Notes
- K&R the C programming language——study notes
- Trading——Study Notes
- Study notes for OpenCV——第六节 写视频文件
- CSS Study Notes— Selectors for Class/Div/Attribute
- study notes
- Notes 1 of More Effective C++ —— Basics
- Study notes for OpenCV——第一节:环境的搭建与配置
- Study notes for OpenCV——第二节:Opencv的结构与内容
- Study notes for OpenCV——第三节:Opencv一个简单的程序:显示图像
- Study notes for OpenCV——第四节:Opencv读取视频
- Study notes for OpenCV——第五节:视频播放控制
- Study notes for OpenCV——第七节 OpenCV基本数据结构
- Study notes for OpenCV——第八节 CvMat结构体与矩阵的创建
- Study notes for OpenCV——第九节 矩阵的维度、通道和矩阵的访问
- SharePoint2013 Study Notes— How to Create a Event Receiver and Add Feature Event Receivers
- JQuery Study Notes— A small demo for unfolding its content
- JQuery Study Notes— A small demo for Smooth Animated Menu
- insmod 加载模块的过程
- maven+spring+springmvc+mybatis+ajax 框架下实现简单的聊天室
- 应用启动时间-性能测试
- 是看好款式
- Http状态码大全
- Effective C++——Study Notes
- Rational Rose 2003 逆向工程转换C++ / VC++ 6.0源代码成UML类图
- 约瑟夫环问题
- 毕业的感悟
- 招投标的领悟
- 黄岛麦凯乐
- Ubuntu10拼音输入法设置
- C++继承学习笔记
- ioctl 与unlocked_ioctl