当前位置: 首页 > news >正文

有那些专门做财务分析的网站安阳市商祺网络有限责任公司

有那些专门做财务分析的网站,安阳市商祺网络有限责任公司,网页翻译成中文怎么设置,中国网站有哪些C 23种设计模式 ■ 创建型模式(5种)■ 工厂模式■ 抽象工厂模式■ 原型模式■ 单例模式■ 第一种#xff1a;单线程#xff08;懒汉#xff09;■ 第二种#xff1a;多线程#xff08;互斥量实现锁懒汉#xff09;■ 第三种#xff1a;多线程#xff08;const static饿… C 23种设计模式 ■ 创建型模式(5种)■ 工厂模式■ 抽象工厂模式■ 原型模式■ 单例模式■ 第一种单线程懒汉■ 第二种多线程互斥量实现锁懒汉■ 第三种多线程const static饿汉还要继续了解 ■ 建造者模式 ■ 结构型模式(7种)■ 适配器模式■ 桥接模式■ 组合实体模式■ 装饰器模式■ 外观模式■ 享元模式■ 代理模式 ■ 行为型模式(11种)■ 责任链模式■ 中介者模式■ 策略模式■ 模板模式■ 状态模式■ 观察者模式■ 备忘录模式■ 命令模式■ 访问者模式■ 解释器模式■ 迭代器模式 ■ 创建型模式(5种) ■ 工厂模式 示例一 #includeiostream #includestring using namespace std; enum CTYPE{COREA,COREB}; //定义一个基类单核 class SingleCore { public:virtual void show() 0; }; //单核A class SingleCoreA:public SingleCore { public:void show() {cout SingleCore A endl;} }; //单核B class SingleCoreB:public SingleCore { public:void show() {cout SingleCore B endl;} }; //唯一的工厂可以生成A、B两种处理器核在内部判断 class Factory { public://基类的对象指针指向子类的对象也就是多态SingleCore* CreateSingleCore(CTYPE ctype){//工厂内部判断if (ctype COREA){//生产核Areturn new SingleCoreA();}else if (ctype COREB){//生产核Breturn new SingleCoreB();}else {return NULL;}} }; int main() {Factory* factor new Factory();factor-CreateSingleCore(COREA)-show();getchar();return 0; } ■ 抽象工厂模式 ■ 原型模式 ■ 单例模式 ■ 第一种单线程懒汉 //单线程解法 //这种解法在多线程的情况下可能创建多个实例。 class Singleton1 { private:static Singleton1* m_pInstance1;//需要的时候才创建懒汉//利用static关键字的特性不属于任何类整个类只有一个Singleton1(); public:static Singleton1* GetInstance1();static void DestroyInstance1(); }; Singleton1::Singleton1() {cout 创建单例 endl; } Singleton1* Singleton1::GetInstance1() {return m_pInstance1; } void Singleton1::DestroyInstance1() {if (m_pInstance1 ! nullptr){delete m_pInstance1;m_pInstance1 nullptr;} }//初始化一个对象 Singleton1* Singleton1::m_pInstance1 new Singleton1();//单线程下多次获取实例 void test1() {Singleton1* singletoObj1 Singleton1::GetInstance1();cout singletoObj1 endl;Singleton1* singletoObj2 Singleton1::GetInstance1();cout singletoObj2 endl;//上面的两个对象会指向同一个地址Singleton1::DestroyInstance1(); }■ 第二种多线程互斥量实现锁懒汉 //多线程加锁互斥量 class Singleton2 { private:Singleton2();static Singleton2* m_pInstance2;static mutex m_mutex;//互斥量 public:static Singleton2* GetInstance2();static void DestroyInstance2(); };Singleton2::Singleton2() {cout 创建单例2 endl; } Singleton2* Singleton2::GetInstance2() {if (m_pInstance2 nullptr){cout 加锁中 endl;m_mutex.lock();if (m_pInstance2 nullptr){m_pInstance2 new Singleton2();}cout 解锁中 endl;m_mutex.unlock();}return m_pInstance2; } void Singleton2::DestroyInstance2() {if (m_pInstance2 ! nullptr){delete m_pInstance2;m_pInstance2 nullptr;} } //静态成员变量的定义 Singleton2* Singleton2::m_pInstance2 nullptr;//懒汉式的写法 mutex Singleton2::m_mutex;//常见一个实例对象给下面的多线程调用 void print_singleton_instance() {Singleton2* singletonObj2 Singleton2::GetInstance2();cout 新的一个实例对象 singletonObj2 endl; }void test2() {vectorthread threads;for (int i 0; i 10; i){//十个线程都指向同一个静态变量的地址threads.push_back(thread(print_singleton_instance));}for (auto thr : threads){thr.join();} }■ 第三种多线程const static饿汉还要继续了解 //方案三使用const特性来替换方案二的加锁操作 class Singleton3 { private:Singleton3(){}static const Singleton3* m_pInstance3; public:static Singleton3* GetInstance3();static void DestroyInstance3(); };Singleton3* Singleton3::GetInstance3() {//这个函数的返回值如果变化曾const static属性就不用进行const_castreturn const_castSingleton3* (m_pInstance3); }void Singleton3::DestroyInstance3() {if (m_pInstance3 ! nullptr){delete m_pInstance3;m_pInstance3 nullptr;} }//静态成员变量的定义 const Singleton3* Singleton3::m_pInstance3 new Singleton3();//饿汉式的写法//常见一个实例对象给下面的多线程调用 void print_singleton_instance3() {Singleton3* singletonObj3 Singleton3::GetInstance3();cout 新的一个实例对象 singletonObj3 endl; }void test3() {vectorthread threads;for (int i 0; i 10; i){//十个线程都指向同一个静态变量的地址threads.push_back(thread(print_singleton_instance3));}for (auto thr : threads){thr.join();} }■ 建造者模式 ■ 结构型模式(7种) ■ 适配器模式 ■ 桥接模式 ■ 组合实体模式 ■ 装饰器模式 ■ 外观模式 ■ 享元模式 ■ 代理模式 ■ 行为型模式(11种) ■ 责任链模式 ■ 中介者模式 ■ 策略模式 ■ 模板模式 ■ 状态模式 ■ 观察者模式 ■ 备忘录模式 ■ 命令模式 ■ 访问者模式 ■ 解释器模式 ■ 迭代器模式
http://www.w-s-a.com/news/114276/

相关文章:

  • 建站技术博客wordpress响应时间
  • 农业网站模板WordPress安徽省建设工程造价管理协会网站
  • 网站后台策划书破解版手游app平台
  • 宿迁网站建设介绍公司wordpress 文章 分类 页面
  • 建设通同类网站网站设计公司种类
  • 台州专业做网站网站可以个人做吗
  • 个人logo在线生成免费乐陵德州seo公司
  • 网站回答问题app怎么做专业定制网红柴火灶
  • 网站做的最好的公司行业网址大全
  • 内网怎么做网站服务器seo统计
  • 丽水市企业网站建设 微信营销 影视拍摄计算机专业吃香吗
  • 龙岗做网站公司哪家好找到做网站的公司
  • 网站图片alt属性wordpress 自定义栏目 调用
  • 怎样建网站最快广州网站建设工程
  • iis7 网站404错误信息12306网站很难做吗
  • 网站建设600元包公司设计图片大全
  • 网站建设费用怎么做分录做校园网站代码
  • 网站改版做重定向福州网站建设思企
  • 网站建设全流程企业形象网站开发业务范畴
  • wordpress无法查看站点西安优秀高端网站建设服务商
  • 固始网站制作熟悉免费的网络营销方式
  • 做网站到a5卖站赚钱搜索引擎优化代理
  • 沈阳网站建设包括win10优化
  • 做百度手机网站点击软网站seo优化徐州百度网络
  • 徐州专业网站制作标志设计作业
  • 自己可以做网站空间吗海天建设集团有限公司网站
  • 教学督导网站建设报告aspcms网站图片不显示
  • 网站开发公司成本是什么门户网站宣传方案
  • 上海 企业网站建设网站怎么开通微信支付
  • 饮料网站建设wordpress主题猫