將一個類接口封裝成另一類接口。
代碼示例:
class Adaptee
{
public:
void SpecificRequest();
};
class Adapter
{
public:
void Request()
{Adaptee::SpecificRequest();}
};
1.底層模塊爲上層模塊提供接口,當底層模塊改變時,不希望重新定義上層模塊,在中間添加一層Adapter模塊進行對接;
2.不同的類適配到一個算法,例如:iterater
將一個類接口封裝成另一類接口。
代碼示例:
class Adaptee
{
public:
void SpecificRequest();
};
class Adapter
{
public:
void Request()
{Adaptee::SpecificRequest();}
};
1.底層模塊爲上層模塊提供接口,當底層模塊改變時,不希望重新定義上層模塊,在中間添加一層Adapter模塊進行對接;
2.不同的類適配到一個算法,例如:iterater