アイデア:抽象的アルゴリズム、その後、ブリッジモードを使用するには、全体的な置換アルゴリズムの目的を達成するためのアルゴリズムに抽象インタフェースを使用しています
理解:ブリッジモードブリッジ別のアイデアの同じ、ちょうど異なる側
例:
クラスAlgrithm //算法的抽象 { パブリック: 仮想ボイドalgrithm()= 0; }。 クラスAlgrithmA:公共Algrithm { パブリック: ボイドalgrithm() { COUT << "AlgrithmA" << ENDL。 } }。 クラスAlgrithmB:公共Algrithm { パブリック: ボイドalgrithm() { COUT << "AlgrithmB" << ENDL。 } }。
クラス内容 { Algrithm * pAlgrithm。//桥接模式 公共: コンテンツ(Algrithm * pAlgrithm) { this-> pAlgrithm = pAlgrithm。 } 行わボイド() { this-> pAlgrithm-> algrithm(); } }。
メインINT() { コンテンツT1(新しいAlgrithmA())。 t1.done(); コンテンツT2(新AlgrithmB()); t2.done(); 0を返します。 }