《Effective C++》摘要

Date:
Categories: C++
Author: sysublackbear
Tags:

看了下《Effective C++》这本书,整理了下面的一些摘要。

Chapter0.导读

1.explict抑制隐式转换

例如:

class B {
public:
  explicit B(int x = 0, bool b = true);   //default构造函数,抑制隐私zh
}

2.理解拷贝构造和拷贝赋值的区别

class Widget {
public:
     Widget();                                                   //default构造函数
     Widget(const Widget& rhs);                    //copy构造函数
     Widget& operator=(const Widget& rhs);  //copy assignment操作符
     ...
};

Widget w1;          //调用default构造函数
Widget w2;          //调用copy构造函数
w1 = w2 ...