c++默认构造函数
#include <iostream>
using namespace std;
class myClass
{
private:
int a;
public:
myClass(int b = 0):a(b) {}
myClass():a(0) {}
int GetA() const
{
cout << this->a << endl;
}
};
int main()
{
myClass myObject(7);
myObject.GetA();
myClass myObject1(); //为什么不给myObject1()传递参数不行??
myObject1.GetA();
return 0;
}