码迷,mamicode.com
首页 > 其他好文 > 详细

单例类

时间:2019-02-13 22:32:18      阅读:172      评论:0      收藏:0      [点我收藏+]

标签:padding   argv   back   let   space   ios   amp   pad   clu   

记录一下一个最简单的单例类的实现。

#include "stdafx.h"
#include <stdio.h>
#include <iostream>

using namespace std;

class Singleton
{
public:
    static Singleton& GetInstance()
    {
        static Singleton instance_;
        return instance_;
    }

    ~Singleton()
    {
        cout << "~Singleton" << endl;
    }
public:

    Singleton()
    {
        cout << "Singleton " << endl;
    }
    Singleton(const Singleton &other);
    Singleton & operator=(const Singleton &other);
};


int _tmain(int argc, _TCHAR* argv[])
{
    Singleton& slt = Singleton::GetInstance();
    return 0;
}

单例类

标签:padding   argv   back   let   space   ios   amp   pad   clu   

原文地址:https://www.cnblogs.com/betterwgo/p/10372150.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!