标签:
目的
void Application::openDocument(const char* name)
{
if(!canOpenDocument(name))
return;
Document* doc = createDocument();
if(doc != NULL)
{
m_docs->addDocument(doc);
aboutToOpenDocument(doc);
doc->open();
doc->read();
}
}
class Application
{
public:
void openDocument(const char* name);
protected:
virtual void canOpenDocument(const char* name);
virtual void createDocument();
virtual void aboutToOpenDocument();
private:
vector<Document*> m_docs;
};
class MyApplication : public Application
{
protected:
virtual Document* createDocument();
virtual void aboutToOpenDocument();
};
Document* MyApplication::createDocument()
{
return new MyDocument();
}
void aboutToOpenDocument()
{
// initialize doc object.
}
标签:
原文地址:http://blog.csdn.net/harrising/article/details/38147255