Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 软件时空 > 软件相关 > [bingo]模式学习笔记四 Prototype & Singleton
【标  题】:[bingo]模式学习笔记四 Prototype & Singleton
【关键字】:bingo,Prototype,Singleton
【来  源】:http://blog.chinaunix.net/article.php?articleId=27352&blogId=2677

[bingo]模式学习笔记四 Prototype & Singleton

Your Ad Here

四. Prototype(原型) & Singleton(单件)

Prototype通过对已有对象的Clone生成一个新的对象。
Singleton保证一个类只有一个对象,并提供一个全局访问点。

Singleton的经典代码:
class myclass
{
public:
    static myclass *Instance();
protected:
    myclass(); 
private:
    static myclass *_instance;
}

myclass* myclass::_instance = 0;

myclass *myclass::Instance()
{
    if(_instance == 0)
    {
        _instance = new myclass;
    }
    return _instance;
}

这里实在太慢了,转到blogchina了:【上一篇】
.net环境下编译c++:【下一篇】
【相关文章】
  • constructor in singleton pattern
  • [bingo]Linux Shell复习笔记
  • [bingo] Linux正则表达式
  • [bingo] Linux grep 使用
  • [bingo]Linux内核模块开发<一>
  • [bingo] Iptables笔记1-introduce&conntrack
  • [bingo] Iptables笔记2-规则的编写
  • [bingo]openssl文档笔记一
  • Lazy Singleton的Java实现
  • 使用singleton
  • 【随机文章】
  • 用JSP操作Cookie
  • G.SHDSL技术成为宽带接入新亮点
  • 名车风景线!《极品飞车 头号悬赏》收录车辆公布
  • 使用Apache的mod_gzip对WEB服务器进行HTTP压缩优化
  • SA119读书笔记第三章
  • 让人头痛的 Wine
  • 把状态机呈现给用户是拙劣的设计
  • PowerDesigner 自定义报表输出项
  • 深入理解Linux操作系统下的守护进程
  • SCO TCP/IP网络管理---信任关系
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.