Default Constructor: C++ Compiler generates automatically if you don't define one.
以class Time为例 :
系统自生成默认构造函数为:
Time::Time() {} // implicit and does nothing
定义一个类变量时:
Time curTime; // 类没有初始化
自定义构造函数: 【避免构建两个相同的构造函数】
Time::Time(int h=0, int m=0) { hours = h; minutes = m; }
Time::Time() { hours = 0; minutes = 0; }
以上两个一起定义会出错:
error: call of overloaded 'Time()' is ambiguous