ClassName instance()
我有一个问题:在 C++ 中创建类的实例时使用什么构造函数?
例子:
#include <iostream>
using namespace std;
class Test
{
private:
Test()
{
cout << "AAA" << endl;
}
public:
Test(string str)
{
cout << "String = " << str << endl;
}
};
int main()
{
Test instance_1(); // instance_1 is created... using which constructor ?
Test instance_2("hello !"); // Ok
return 0;
}
谢谢 !