2017年8月30日

Effective C++ 条款10

摘要: 令operator= 返回一个reference to *this. Have assignment operators return a reference to *this. 赋值时,我们可以写成如下形式: int x,y,z; x=y=z=10; 这种连锁方式采用右结合方式,也就是 x=(y= 阅读全文

posted @ 2017-08-30 14:01 ^~~^ 阅读(85) 评论(0) 推荐(0) 编辑

Effective C++ 条款09

摘要: 绝不在构造/析构函数中调用virtual函数。 Never call virtual functions during construction and destruction. 在构造/析构函数中调用virtual函数,会导致链接失败,因为这里编译器不会执行多态操作,将虚函数调用传递到derive 阅读全文

posted @ 2017-08-30 13:46 ^~~^ 阅读(101) 评论(0) 推荐(0) 编辑

Effective C++ 条款08

摘要: 别让异常逃离析构函数 Prevent exceptions from leaving destructors 析构函数绝对不要抛出异常,如果一个被析构函数调用的函数可能抛出异常,那么析构函数应该处理这个异常并且不能抛出。 这里的理解是,如果一个析构函数抛出异常,会导致当前对象处于未定义状态或者导致程 阅读全文

posted @ 2017-08-30 13:42 ^~~^ 阅读(91) 评论(0) 推荐(0) 编辑

导航