bridge.h
来自「设计模式C++源码(other)Bridge.rar」· C头文件 代码 · 共 109 行
H
109 行
/** * bridge.h * Implemented by Blueprint Technologies, Inc. */#ifndef _bridge_h#define _bridge_h/** * Defines the interface for implementation classes. This * interface doesn't have to correspond exactly to Abstraction's * interface; in fact the two interfaces can be quite different. * Typically the Implementor interface provides only primitive * operations, and Abstraction defines higher-level operations * based on these primitives. */class Implementor{public: virtual void operationImp() = 0;};/** * Implements the Implementor interface and defines its * concrete implementation. */class ConcreteImplementorA: public Implementor{public: virtual void operationImp() { // Do something. };};/** * Implements the Implementor interface and defines its * concrete implementation. */class ConcreteImplementorB: public Implementor{public: virtual void operationImp() { // Do something. };};/** * Defines the abstraction's interface. Maintains a reference * to an object of type Implementor. */class Abstraction{private: Implementor* implementor;public: Abstraction(): implementor(0) { }; virtual void operation() { implementor -> operationImp(); }; void setImplementor( Implementor* implementor ) { this -> implementor = implementor; }; Implementor* getImplementor() { return implementor; };};/** * Extends the interface defined by Abstraction. */class RefinedAbstraction: public Abstraction{public: virtual void operation() { Abstraction::operation(); /** * new behavior here. */ };};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?