class Document {};class MyDocument : public Document {};class Application{public: virtual Document *CreateDocument() = 0;};class MyApplication : public Application{public: virtual Document *CreateDocument() override { return new MyDocument; }};
其中, CreateDocument 就是 Factory Method.
主要意图就是将实例化的时机延后到子类.