```
#include <iostream>
#include <string>
using namespace std;
class Shape {
public:
virtual void Draw() = 0;
static Shape* ShapeFactory(string type);
};
class Circle : public Shape {
public:
void Draw() { cout << "I am circle" << endl; }
friend class Shape;
};
class Square : public Shape {
public:
void Draw() { cout << "I am square" << endl; }
friend class Shape;
};
Shape* Shape::ShapeFactory(string type) {
if ( type == "circle" ) return new Circle();
if ( type == "square" ) return new Square();
return NULL;
}
int main(){
Shape* obj1 = Shape::ShapeFactory("circle");
Shape* obj2 = Shape::ShapeFactory("square");
obj1->Draw();
obj2->Draw();
}
/*
I am circle
I am square
*/
```