Papers/Design pattern
factory method
tomato13
2007. 7. 8. 17:16
class shape
{
public:
shape() {};
~shape() {};
virtual void draw() = 0;
};
class square : public shape
{
public:
square() {};
~square() {};
void draw()
{
cout << "square is drawn\n" << endl;
}
};
class circle : public shape
{
public:
circle() {};
~circle() {};
void draw()
{
cout << "circle is drawn\n" << endl;
}
};
int main()
{
shape* pShape = (circle*)new circle();
pShape->draw();
return 1;
}
http://www.javacamp.org/designPattern/factory.html
http://en.wikipedia.org/wiki/Factory_method_pattern