//FactoryPattern.h#pragma once
#include <memory>
enumShapeType{CIRCLE,RECTANGLE};classShape{public:Shape();virtual~Shape();virtualvoidDraw()=0;constShapeType&getType(){returntype;};protected:ShapeTypetype;};classCircle:publicShape{public:Circle();virtual~Circle();virtualvoidDraw();staticstd::shared_ptr<Circle>SafeDownCast(std::shared_ptr<Shape>pShape);private:doubleradius;};classRectangle:publicShape{public:Rectangle();virtual~Rectangle();virtualvoidDraw();staticstd::shared_ptr<Rectangle>SafeDownCast(std::shared_ptr<Shape>pShape);private:doublelength;doublewidth;};classShapeFactory{public:ShapeFactory();~ShapeFactory();staticstd::shared_ptr<Shape>CreateShape(constShapeType&type);};