#include
class CRoundShape
{
public:
virtual ~CRoundShape() { }
virtual void m_doRound() const=0;
};
class CSquareShape
{
public:
virtual ~CSquareShape() { }
virtual void m_doSquare() const=0;
};
class CRound_Hole
{
public:
void m_insert(const CRoundShape & shape) const
{
shape.m_doRound();
}
};
class CSquareShapeAdapter : public CRoundShape
{
private:
CSquareShape & square_shape;
public:
CSquareShapeAdapter(CSquareShape & shape) : square_shape(shape){ }
void m_doRound() const
{
square_shape.m_doSquare();
}
};
class CDisplayMessage : public CSquareShape
{
public:
void m_doSquare() const
{
std::cout << "ccplusplus.com" << std::endl;
}
};
void display_message(const CRoundShape & shape)
{
CRound_Hole().m_insert(shape);
}
int main()
{
CDisplayMessage shape;
display_message(CSquareShapeAdapter(shape));
return 0;
}
adapter design pattern example in C++
adapter design pattern example in C++, adapter design in C plus plus, CSquareShapeAdapter Class in C++, using CSquareShapeAdapter in C++
I think this is one of the most significant information for me. And i am glad reading your article. But should remark on few general things, The site style is great, the articles is really nice : D. Good job, cheers
ReplyDeleteUnderworks Nylon Maxi Length Half Slips with Snip a Length 3-Pack