代码拉取完成,页面将自动刷新
//桥接模式 Abstraction operation
#include<iostream>
using namespace std;
class AbstractionImp{
public:
virtual void Operation()=0;
virtual ~AbstractionImp(){}
};
class AbstractionImpA:public AbstractionImp{
public:
void Operation(){
cout<<"AbstractionA.com"<<endl;
}
};
class AbstractionImpB:public AbstractionImp{
public:
void Operation(){
cout<<"AbstractionB.com"<<endl;
}
};
class Abstraction{
protected:
AbstractionImp * pb;
public:
Abstraction(AbstractionImp * t){
pb=t;
}
virtual void Operation()=0;
virtual ~Abstraction(){
delete pb;
}
};
class AbstractionA:public Abstraction{
public:
AbstractionA(AbstractionImp * t):Abstraction(t){}
void Operation(){
pb->Operation();
}
};
class AbstractionB:public Abstraction{
public:
AbstractionB(AbstractionImp * t):Abstraction(t){}
void Operation(){
pb->Operation();
}
};
int main(void)
{
Abstraction * my=new AbstractionA(new AbstractionImpA());
my->Operation();
delete my;
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。