c++ singleton 懒汉模式(Meyers)VC6编译不过
class Singleton
{
public:
static Singleton& Instance() {
static Singleton theSingleton;
return theSingleton;
}
private:
Singleton(); // ctor hidden
Singleton(Singleton const&); // copy ctor hidden
Singleton& operator=(Singleton const&); // assign op. hidden
~Singleton(); // dtor hidden
};
错误:
error C2248: 'Singleton::~Singleton' : cannot access private member declared in class 'Singleton'
我把析构函数改成public就可以编过了,如果说不能访问私有成员的话构造也是私有的为什么不报错,哪位大侠知道原因么?