设计模式(Bridge)
来源:互联网 发布:淘宝流量来源 360搜索 编辑:程序博客网 时间:2024/05/22 03:33
// Abstraction.h: interface for the CAbstraction class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ABSTRACTION_H__EEDB1B76_5760_4067_A2CB_95604AE082E4__INCLUDED_)
#define AFX_ABSTRACTION_H__EEDB1B76_5760_4067_A2CB_95604AE082E4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CAbstractionImp;
class CAbstraction
{
public:
CAbstraction(CAbstractionImp *pAbstrationImp);
virtual ~CAbstraction();
protected:
CAbstraction();
public:
virtual void Func(void) = 0;
protected:
CAbstractionImp *m_pAbstractionImp;
};
class CRefindedAbstraction : public CAbstraction
{
public:
CRefindedAbstraction(CAbstractionImp *pAbstrationImp);
virtual ~CRefindedAbstraction();
public:
void Func(void);
};
#endif // !defined(AFX_ABSTRACTION_H__EEDB1B76_5760_4067_A2CB_95604AE082E4__INCLUDED_)
// Abstraction.cpp: implementation of the CAbstraction class.
//
//////////////////////////////////////////////////////////////////////
#include "Abstraction.h"
#include "AbstractionImp.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAbstraction::CAbstraction()
{
}
CAbstraction::CAbstraction(CAbstractionImp *pAbstractionImp)
{
m_pAbstractionImp = pAbstractionImp;
}
CAbstraction::~CAbstraction()
{
}
/////////////////////////////////////////////////////////
CRefindedAbstraction::CRefindedAbstraction(CAbstractionImp *pAbstractionImp)
: CAbstraction(pAbstractionImp)
{
}
CRefindedAbstraction::~CRefindedAbstraction()
{
}
void CRefindedAbstraction::Func()
{
m_pAbstractionImp->Func();
}
// AbstractionImp.h: interface for the CAbstractionImp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ABSTRACTIONIMP_H__29762645_3054_47C4_BF33_D8DACB518CD5__INCLUDED_)
#define AFX_ABSTRACTIONIMP_H__29762645_3054_47C4_BF33_D8DACB518CD5__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CAbstractionImp
{
public:
CAbstractionImp();
virtual ~CAbstractionImp();
public:
virtual void Func(void) = 0;
};
class CAbstractionImpA : public CAbstractionImp
{
public:
CAbstractionImpA();
virtual ~CAbstractionImpA();
public:
void Func(void);
};
class CAbstractionImpB : public CAbstractionImp
{
public:
CAbstractionImpB();
virtual ~CAbstractionImpB();
public:
void Func(void);
};
#endif // !defined(AFX_ABSTRACTIONIMP_H__29762645_3054_47C4_BF33_D8DACB518CD5__INCLUDED_)
// AbstractionImp.cpp: implementation of the CAbstractionImp class.
//
//////////////////////////////////////////////////////////////////////
#include "AbstractionImp.h"
#include <iostream>
using namespace std;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAbstractionImp::CAbstractionImp()
{
}
CAbstractionImp::~CAbstractionImp()
{
}
/////////////////////////////////////////////
CAbstractionImpA::CAbstractionImpA()
{
}
CAbstractionImpA::~CAbstractionImpA()
{
}
void CAbstractionImpA::Func()
{
cout<<"CAbstractionImpA::Func"<<endl;
}
/////////////////////////////////////////////
CAbstractionImpB::CAbstractionImpB()
{
}
CAbstractionImpB::~CAbstractionImpB()
{
}
void CAbstractionImpB::Func()
{
cout<<"CAbstractionImpB::Func"<<endl;
}
//main
#include "Abstraction.h"
#include "AbstractionImp.h"
void main()
{
CAbstractionImp *pAbstractionImp = new CAbstractionImpB();
CAbstraction *pAbstraction = new CRefindedAbstraction(pAbstractionImp);
pAbstraction->Func();
delete pAbstraction;
delete pAbstractionImp;
}
- 设计模式----Bridge模式
- 设计模式:Bridge模式
- 设计模式----Bridge模式
- 设计模式 -- Bridge模式
- 设计模式-Bridge模式
- 【设计模式】bridge模式
- 设计模式----Bridge模式
- 设计模式--------Bridge模式
- 设计模式-Bridge模式
- 设计模式 - Bridge模式
- 设计模式--Bridge 模式
- 设计模式之Bridge
- 设计模式之Bridge
- 设计模式之Bridge
- 设计模式二:bridge
- 设计模式之Bridge
- 设计模式之Bridge
- 设计模式之Bridge
- hiberante 中generator属性的所示意义
- 通用SQL数据库的查询语句 (1)
- 设计模式(Abstract Factory)
- 群里一位老大贴的排序算法
- 工具集
- 设计模式(Bridge)
- MySQL联合创始人向Sun递交辞呈
- 设计模式(Adapter)
- ASP.NET 2.0服务器控件与组件开发高级编程
- 设计模式(Facade)
- 我的小站
- BASH使用详解
- 一些异常精妙的"SQL"语句
- 编写一个简单的Web Service