The Default Constructor
The default constructor is the constructor used to create an object when you don't provide explicit initialization values. That is, it's the constructor used for declarations like this:
Stock stock1; // uses the default constructor
1、由编译器自动生成
2、由我们自己定义的
这里又有两种情况
上面说了啊,default constructor有两种(……your own default constructor. This is a constructor that takes no arguments):
1)One is to provide default values for all the arguments to the existing constructor:
Stock(const char * co = "Error", int n = 0, double pr = 0.0);
2)The second is to use function overloading to define a second constructor, one that has no arguments:
Stock();
有一点注意的时候两者不能同时使用:
You can have only one default constructor, so be sure that you don't do both. (With early versions of C++, you could use only the second method for creating a default constructor.)
This is a constructor that takes no arguments:这个指的是调用的时候不带参数。
编译器自动添加默认构造函数的条件:编译器实现的构造函数其实就是什么都不做
1.没有任何自己定义的构造函数(即便是复制构造函数也不行,如果自己定义复制构造函数,则必须自己定义构造函数)
2、数据成员中没有const和reference。–因为要初始化。
拷贝构造函数的参数必须是引用的原因:拷贝构造函数的参数使用引用类型不是为了减少一次内存拷贝, 而是避免拷贝构造函数无限制的递归下去。
如果是值的话,那在传值的时候还要再调一次拷贝构造函数
然后又要传值,又要再调一次….
然后你就内存不够,当了

