标签:工厂 virtual
#include <iostream> using namespace std; class PDFParser{ public: void parse(const char* pdffile){ onRect(); onCircle();//注意这里,可以这么写. onText(); onImage(); } private: virtual void onRect(void) = 0; virtual void onCircle(void) = 0; virtual void onText(void) = 0; virtual void onImage(void) = 0; }; class PDFRender:public PDFParser{ private: void onRect(void){ cout << "hua yi ge rect" << endl; } void onCircle(void){ cout << "hua yi ge Circle" << endl; } void onText(void){ cout << "hua yi ge Text" << endl; } void onImage(void){ cout << "hua yi ge image"<< endl; } }; int main(void){ PDFRender render; render.parse("some.pdf"); return 0; }
hua yi ge rect
hua yi ge Circle
hua yi ge Text
hua yi ge image
本文出自 “12208412” 博客,请务必保留此出处http://12218412.blog.51cto.com/12208412/1868690
标签:工厂 virtual
原文地址:http://12218412.blog.51cto.com/12208412/1868690