• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            C++研究

            C++細(xì)節(jié)深度探索及軟件工程

              C++博客 :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
              37 隨筆 :: 0 文章 :: 74 評(píng)論 :: 0 Trackbacks
            The Gof has 23 design patterns , but in most of  the design books , the E.G is written in Java , So  from now on , I will write about 23 articles to implement them using C++ , the design pattern itself is discussible , so welcome everyone to give his excelent idea to me , My QQ: 286259397 And My MSN : cxl82116@msn.com.
            Welcome every one to express his ideas!

             

            This is the Third Arcticle: Bridge PATTERN

            T
            he Bridge pattern separate the impelment part  and the abstract part , so that they can variant each other



                                             3.1          Bridge -Pattern  UML Diagram
            Referring the UML , The C# Codes goes Here:

             1namespace BridgeDesignPattern
             2{
             3    abstract class TSquare
             4    {
             5        public abstract void OnKey();
             6        public abstract void Conflict();
             7        public abstract void Glitter();
             8    }
            ;
             9
            10    class TSquareHole : TSquare
            11    {
            12        private TSquareImp _imp;
            13        public TSquareHole(TSquareImp _imp)
            14        {
            15            this._imp = _imp;
            16        }

            17        public override void OnKey()
            18        {
            19            _imp.OnKey();
            20        }

            21        public  override void  Conflict()
            22        {
            23            _imp.Conflict();
            24        }

            25        public override void Glitter()
            26        {
            27            _imp.Glitter();
            28        }

            29    }
            ;
            30
            31    abstract class TSquareImp
            32    {
            33        public abstract void OnKey();
            34        public abstract void Conflict();
            35        public abstract void Glitter();
            36
            37    }
            ;
            38    class TPCSquareHoleImp : TSquareImp
            39    {
            40        public override void OnKey()
            41        {
            42            Console.WriteLine("TPCSquareHoleImp On key");
            43
            44        }

            45        public override void Conflict()
            46        {
            47            Console.WriteLine("TPCSquareHoleImp Conflict");
            48        }

            49        public override void Glitter()
            50        {
            51            Console.WriteLine("TPCSquareHoleImp Glitter");
            52        }

            53    }
            ;
            54    class TMobileSquareHoleImp:TSquareImp
            55    {
            56            public override void OnKey()
            57            {
            58                Console.WriteLine("TMobileSquareHoleImp On key");
            59
            60            }

            61            public override void Conflict()
            62            {
            63                Console.WriteLine("TMobileSquareHoleImp Conflict");
            64            }

            65            public override void Glitter()
            66            {
            67                Console.WriteLine("TMobileSquareHoleImp Glitter");
            68            }

            69    }
            ;
                        

             static void Main(string[] args)
                       
            {
                              BridgeDesignPattern.TMobileSquareHoleImp _imp 
            = new BridgeDesignPattern.TMobileSquareHoleImp();
                              BridgeDesignPattern.TSquareHole _hole 
            = new BridgeDesignPattern.TSquareHole(_imp);
                              _hole.OnKey();

                           Console.Read();
                    }



            71 }


            And there is the C++ Code:

             1/********************************************************************
             2    created:    2007/04/24
             3    created:    24:4:2007   2:34
             4    filename:     C:\TESTVC6\TESTSS.CPP
             5    file path:    C:\TESTVC6
             6    file base:    TESTSS
             7    file ext:    CPP
             8    author:        常興龍(King.C)
             9    
            10    purpose:    橋模式
            11*********************************************************************/

            12
            13#include <iostream>
            14#include <vector>
            15
            16using namespace std;
            17class T
            18{
            19public:
            20    virtual void onKey()=0;
            21}
            ;
            22class TImp
            23{
            24public:
            25    virtual void OnKeyImp()=0;
            26}
            ;
            27class TT:public T
            28{
            29public:
            30    TT(TImp *_imp)
            31    {
            32        this->_imp=_imp;
            33    }

            34    void onKey()
            35    {
            36        _imp->OnKeyImp();
            37    }

            38private:
            39  TImp * _imp;
            40}
            ;
            41class T40Imp:public TImp
            42{
            43public:
            44    void OnKeyImp()
            45    {
            46        cout<<"t40 imp"<<endl;
            47    }

            48}
            ;
            49class T50Imp:public TImp
            50{
            51public:
            52    void OnKeyImp()
            53    {
            54        cout<<"t50 imp"<<endl;
            55    }

            56}
            ;
            57void main()
            58{
            59    TImp *_imp=new T40Imp();
            60
            61    TT _tt(_imp);
            62    TImp *_imp2=new T50Imp();
            63    TT _tt2(_imp2);
            64    _tt2.onKey();
            65    _tt.onKey();
            66    
            67    return;
            68}
            posted on 2007-04-24 02:38 常興龍 閱讀(977) 評(píng)論(0)  編輯 收藏 引用 所屬分類: Design Patterns & Engeering
            > hi的博客
            久久www免费人成看片| 色狠狠久久AV五月综合| 久久成人精品| 天天综合久久一二三区| 久久中文字幕人妻熟av女| 精品久久久久久无码专区不卡| 久久久久综合网久久| 秋霞久久国产精品电影院| 亚洲人成电影网站久久| 国产精品久久久久久久久鸭 | 亚洲国产成人精品女人久久久| 99久久综合国产精品免费| 久久九九亚洲精品| 久久99精品久久久大学生| 久久免费美女视频| 久久综合给久久狠狠97色 | 久久精品不卡| 国产精品久久久久9999| 久久人人爽人人爽人人片AV麻烦| 久久精品国产亚洲麻豆| 区久久AAA片69亚洲| 久久久WWW成人免费毛片| 韩国无遮挡三级久久| 精品国产99久久久久久麻豆| 久久av高潮av无码av喷吹| 国产V综合V亚洲欧美久久| 亚洲狠狠婷婷综合久久蜜芽| 色偷偷88欧美精品久久久| 精品久久久久久久久久久久久久久| 久久影院综合精品| 午夜精品久久久久久99热| 狠狠精品久久久无码中文字幕| 日韩美女18网站久久精品| 久久久网中文字幕| 欧美成a人片免费看久久| 国产一区二区精品久久岳| 九九热久久免费视频| 久久久久亚洲精品无码网址 | 久久伊人五月天论坛| 久久99精品久久久久久秒播| 久久国产影院|