Singleton (C++實現)

// Singleton.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class Singleton{public: Singleton(){} virtual ~Singleton(){}  static Singleton* GetInstancePtr() {  if(NULL==m_pStatic)  {   m_pStatic=new Singleton();

Mediator (C++實現)

好文章推薦: http://blog.csdn.net/roynee/archive/2009/10/05/4634197.aspx 下面是簡單實現:(轉載)class Mediator;class Colleage{public:virtual ~Colleage(){};virtual void Action()=0;virtual void SetState(const string& sd)=0;virtual string

Adapter (C++實現 )

// Adapter.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std; class Target{public : Target() {} virtual ~Target(){} virtual  void Request()=0;};class Adaptee{public: Adaptee(){} virtual ~Adaptee(){} void

Iterator (C++實現)

// Iterator.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;typedef int DATA;class Iterator;class Aggregate{public: Aggregate() { } virtual ~Aggregate() { } virtual Iterator* CreateIterator()=0; virtual int

Composite (C++實現)

// Compisite.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <list>#include <algorithm>using namespace std; class Componet{public: Componet() { } virtual ~Componet() { } virtual void Operation()=0; virtual void

Memento (C++實現)

// Memento.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <string> using namespace std; typedef string STATE; class Memento;class Originator{public: Originator(){} Originator(const STATE&

Bridge (C++實現)

// Bridge.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class Implementor{public:   Implementor()  {  }  virtual ~ Implementor()  {  }  virtual void OperationImp()=0;};class ConcreteImpleteorA:public

Proxy (C++實現)

// Proxy.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class Subject{public: Subject() {} virtual ~Subject() {} virtual void Request()=0;};class RealSubject:public Subject{public: RealSubject() {  cout<<"

Facade (C++實現)

// Facade.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class ServiceClass{public: ServiceClass() {  cout<<"Construction of ServiceClas"<<endl; } virtual ~ServiceClass() { } void

Template Method (C++實現)

// Template Method.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class AbstractClass{public: AbstractClass(){} virtual ~AbstractClass(){} // 這個函數中定義了演算法的輪廓 void TemplateMethod() {  PrimitiveOperation1();    

C++中explicit關鍵字的作用

轉載網址: http://www.cnblogs.com/winnersun/archive/2011/07/16/2108440.html explicit用來防止由建構函式定義的隱式轉換。 要明白它的作用,首先要瞭解隱式轉換:可以用單個實參來調用的建構函式定義了從形參類型到該類類型的一個隱式轉換。 class things{   public:       things(const std::string &name = ""):            

State (C++實現)

// State.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std; class State;class Context{public: Context(State* pState); ~Context(); void Request(); void ChangeState(State *pState);private: State *m_pState;}; class

Decorator (C++實現)

// Decorator.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std; class Component{public: Component() { } virtual ~Component() { } virtual void Operation()=0;};   class ConcreteComponent :public

Observer (C++實現)

// Observer.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <list>#include <algorithm> using namespace std; typedef int STATE; class Observer;class Subject{public: Subject() : m_nSubjectState(-1){} virtual

Flyweight (C++實現)

// Flyweight.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <list>#include <string>using namespace std;typedef string STATE;class Flyweight{public: STATE GetIntrinsicState() {  return m_state; } virtual void

Chain of Responsibility (C++實現)

// Chain of Responsibility.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;typedef int Topic;class Handler{public:  Handler(Handler* h= 0, Topic t=-1):successor(h),topic(t)  {  } virtual ~Handler() { }virtual 

Strategy (C++實現)

// Strategy.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>using namespace std;class Strategy;class Context{public: Context(Strategy *pStrategy=NULL):m_pStrategy(pStrategy) { } ~Context() { } void ContextInterface(); void

Visitor (C++實現)

// Visitor.cpp : 定義控制台應用程式的進入點。//#include "stdafx.h"#include <iostream>#include <string>using namespace std;class Visitor;class Element{public: virtual ~Element(){} virtual void Accept(Visitor &rVisitor) =

深入理解C++中關鍵字 mutable

轉載網址:http://dev.yesky.com/393/3007393.shtmlmutalbe的中文意思是“可變的,易變的”,跟constant(既C++中的const)是反義詞。  在C++中,mutable也是為了突破const的限制而設定的。被mutable修飾的變數,將永遠處於可變的狀態,即使在一個const函數中。  我們知道,如果類的成員函數不會改變對象的狀態,那麼這個成員函數一般會聲明成const的。但是,有些時候,我們需要在const的函數裡面修改一些跟類狀態無關的資料成員

關於C++內嵌函式

 轉載網址:http://www.cppblog.com/fwxjj/archive/2007/04/20/22352.html (1)什麼是內嵌函式?(2)為什麼要引入內嵌函式?(3)為什麼inline能取代宏?(4)內嵌函式和宏的區別?(5)什麼時候用內嵌函式?(6)如何使用內嵌函式?(7)內嵌函式的優缺點?(8)如何禁止函數進行內聯?(9)注意事項:  (1)什麼是內嵌函式?內嵌函式是指那些定義在類體內的成員函數,即該函數的函數體放在類體內。 (2)為什麼要引入內嵌函式?當然,引入內嵌函式

總頁數: 4314 1 .... 837 838 839 840 841 .... 4314 Go to: 前往

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.