Singleton单件模板类的用法

Singleton单件模板类的用法

如下类WorkList:
public ref class WorkList
  {
  protected:
   WorkList(void);
  public:
   void AddWork(System::String^ workName, System::String^ ResourceId)
   {
       Console::WriteLine("WorkName:" + workName);
   }
   };
要注意WorkList的构造函数为受保护的并无参数.

Singleton单件模板的用法如下:
Singleton<WorkList>::Instance()->AddWork(workName, ResourceId);

你可能感兴趣的:(Singleton单件模板类的用法)