• <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>
            隨筆-167  評論-8  文章-0  trackbacks-0
            The essence of the Abstract Factory Pattern is to "Provide an interface for creating families of related or dependent objects without specifying their concrete classes".
            class diagram
            uml diagram



             1 /* GUIFactory example */
             2  
             3 #include <iostream>
             4  
             5 class Button {
             6 public:
             7     virtual void paint() = 0;
             8     virtual ~Button() { }
             9 };
            10  
            11 class WinButton : public Button {
            12 public:
            13     void paint() {
            14         std::cout << "I'm a WinButton";
            15     }
            16 };
            17  
            18 class OSXButton : public Button {
            19 public:
            20     void paint() {
            21         std::cout << "I'm an OSXButton";
            22     }
            23 };
            24  
            25 class GUIFactory {
            26 public:
            27     virtual Button* createButton() = 0;
            28     virtual ~GUIFactory() { }
            29 };
            30  
            31 class WinFactory : public GUIFactory {
            32 public:
            33     Button* createButton() {
            34         return new WinButton();
            35     }
            36  
            37     ~WinFactory() { }
            38 };
            39  
            40 class OSXFactory : public GUIFactory {
            41 public:
            42     Button* createButton() {
            43         return new OSXButton();
            44     }
            45  
            46     ~OSXFactory() { }
            47 };
            48  
            49 class Application {
            50 public:
            51     Application(GUIFactory* factory) {
            52         Button* button = factory->createButton();
            53         button->paint();
            54         delete button;
            55         delete factory;
            56     }
            57 };
            58  
            59 GUIFactory* createOsSpecificFactory() {
            60     int sys;
            61     std::cout "\nEnter OS type (0: Windows, 1: MacOS X): ";
            62     std::cin >> sys;
            63  
            64     if (sys == 0) {
            65         return new WinFactory();
            66     } else {
            67         return new OSXFactory();
            68     }
            69 }
            70  
            71 int main() {
            72     Application application(createOsSpecificFactory());
            73 }
            74 
            posted on 2012-11-13 16:46 老馬驛站 閱讀(394) 評論(0)  編輯 收藏 引用 所屬分類: Design pattern
            久久无码一区二区三区少妇| 久久综合精品国产一区二区三区| 伊人久久精品影院| 99久久人妻无码精品系列蜜桃| 亚洲AV日韩精品久久久久久久| 国产成人精品白浆久久69| 久久久精品日本一区二区三区 | 国产精品综合久久第一页| 色妞色综合久久夜夜| 99久久综合狠狠综合久久| 欧美喷潮久久久XXXXx| 久久久久亚洲?V成人无码| 久久国产乱子伦免费精品| 精品久久久久成人码免费动漫 | 麻豆亚洲AV永久无码精品久久| 夜夜亚洲天天久久| 99久久精品日本一区二区免费| 亚洲人成无码网站久久99热国产 | 伊人久久大香线蕉av一区| 久久精品国产精品亚洲| 亚洲国产二区三区久久| 成人久久久观看免费毛片| 亚洲精品白浆高清久久久久久| 亚洲精品久久久www| 精品水蜜桃久久久久久久| 97超级碰碰碰碰久久久久| 99久久精品费精品国产一区二区| 精品多毛少妇人妻AV免费久久 | 久久久久高潮综合影院| 久久久久亚洲精品男人的天堂| 久久国产精品一区二区| 97精品伊人久久大香线蕉app| 久久综合噜噜激激的五月天| 模特私拍国产精品久久| 中文国产成人精品久久不卡| 久久精品aⅴ无码中文字字幕不卡| 欧美亚洲国产精品久久久久| 久久婷婷色香五月综合激情| 国产精品久久久久久久久软件| 久久99热这里只频精品6| 亚洲中文久久精品无码|