C++ 单例模式
来源:互联网 发布:怎样去掉mac上win 编辑:程序博客网 时间:2024/06/06 05:10
代码块
头文件
#include <iostream>class BrowserSetting{public : static BrowserSetting *GetInstance() { if (m_Instance == NULL) { m_Instance = new BrowserSetting(); } return m_Instance; } static void DestoryInstance() { if (m_Instance != NULL) { delete m_Instance; m_Instance = NULL; } } // This is just a operation example int GetWidth() { return m_Width; } int GetHeight() { return m_Height; } void ChangeWidth(int width) { m_Width = width; } void ChangeHeight(int height) { m_Height = height; }private: BrowserSetting() { m_Width = 1360; m_Height = 768; } static BrowserSetting *m_Instance; int m_Width , m_Height;};
引用
BrowserSetting *BrowserSetting::m_Instance = NULL;BrowserSetting *b = BrowserSetting::GetInstance();
阅读全文
0 0
- C#单例模式
- C#-单例模式
- 单例模式(C++)
- 【C++】单例模式
- [C++]单例模式
- 单例模式(C++)
- C ++的单例模式
- 【C++】Chapter17:单例模式
- Object-c单例模式
- Objectove-c单例模式
- Objective C--单例模式
- Objective C--单例模式
- Objective C 单例模式
- Objective C--单例模式
- 单例模式(C#)
- 单例模式(C#)
- object-c 单例模式
- c++-单例模式Singleton
- 南邮Inter多核实验二——Windows环境下多线程程序设计||
- bash基础特性之cut tr 详解与使用
- dpdk程序运行一段时间,收不到包,已解决
- VMware如何进入BIOS方法
- 【STL】uva 10905 Children's Game
- C++ 单例模式
- java实现哲学家进餐问题,及其死锁问题的解决
- Spark on YARN和MapReduce on YARN区别
- ubuntu-ssh no password
- 条件和分支语句
- excel使用技巧汇总
- 如何把一个数的位按四位进行相加
- 左值引用(&)以及右值引用(&&)(原创+转载)
- ACM-Classy