需要注意:
单件模式在写作时,需要对构造函数,析构函数,赋值函数,拷贝构造函数等设置为对外不可见的。
最大程度避免出问题。
// MyInstance.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
class MyInstance
{
public:
private:
private:
};
MyInstance *MyInstance::m_pInstance = NULL;
MyInstance *MyInstance::Instance()
{
}
void MyInstance::SetSalary(int iSalary)
{
}
int MyInstance::GetSalary()
{
}
int main(int argc, char* argv[])
{
}