构造函数在初始化时被调用,不完全正确,比如:
#include <iostream>
using namespace std;
class test
{
public:
static int i;
test()
{
cout<<"called!!"<<endl;
}
};
void main()
{
test* test0;
cout<<"1111"<<endl;
getchar();
}
创建个指针型的对象的时候不会自动调用构造函数,如果new了就会调用,这一点值得注意哦。