我有这个 c++ 类,我想初始化这种类型的对象:
class MyClass
{
public:
/**
* Creates an instance of this class.
* @return Pointer to the created object.
*/
static MyClass * Create ();
protected:
// Explicit protected Constructor
//and Copy-Constructor, use Create() to create an instance of this object.
MyClass();
}
为了创建一个实例,我这样做了:
static MyClass * m_object = myClass.Create();
但我收到了这些警告和错误:
warning C4832: token '.' is illegal after UDT 'MyClass'
error C2275: 'MyClass' : illegal use of this type as an expression
error C2228: left of '.Create' must have class/struct/union
如何正确实例化这个对象?