C# と VB.NET の質問掲示板

わんくま同盟

ASP.NET、C++/CLI、Java 何でもどうぞ

C# と VB.NET の入門サイト


(過去ログ 126 を表示中)
■74856 / )  Re[4]: ヘッダでスレッドセーフなシングルトン
□投稿者/ Atata!! (5回)-(2015/02/02(Mon) 20:45:24)
2015/02/02(Mon) 20:50:53 編集(投稿者)
VC++固有の処理で良いなら、__declspec(selectany)を使うことができます。

class MyPool
{
    static MyPool __instance;

    MyPool()
    {
        // いろいろ処理...
    }

    MyPool(const MyPool& rhs);
    const MyPool& operator =(const MyPool& rhs);

public:
    static MyPool& GetInstance()
    {
        return __instance;
    }
};

__declspec(selectany) MyPool MyPool::__instance;

返信 編集キー/


管理者用

- Child Tree -