This article is organized by Code Assistant software to publish content unrelated to the software
more enjoyable reading, more enjoyable writing, easier publishing
SDI cognition
By simply creating SDI from the wizard, adding features and not looking into the details of SDI, now take a look at the time to learn the Ribbon interface that VS2010 comes with.
A constructor protected type
class Public CFrameWndEx{ protected://Only from serialization to create CMainFrame(); Declare_dyncreate(CMainFrame)
Public CDocument{protected://Only from serialization to create Ctttdoc(); Declare_dyncreate(ctttdoc)
TView &NBSP: public cview { Protected://Create only from serialization ctttview ( ; Declare_dyncreate ctttview" //attribute public : ctttdoc* getdocument ( " const ;
Declared as a protected type, you cannot instantiate a class directly, because MS has been dynamically instantiated in the app initialization function.
By default, CMainFrame cannot be instantiated directly, but is dynamically instantiated in the app's App::initinstance () by Runtime_class
Registers the application's document template. The document Template//will use the connection between the composition document, frame window and view csingledoctemplate* pdoctemplate; Pdoctemplate=New CSingleDocTemplate(Idr_mainframe, Runtime_class(Ctttdoc), Runtime_class(CMainFrame),//main SDI frame window Runtime_class(Ctttview));if(!pdoctemplate)return FALSE; AddDocTemplate(Pdoctemplate);
The second destructor is virtual
Implement public: Virtual ~cmainframe();
Implement public: Virtual ~ctttdoc();
Implement public: Virtual ~ctttview();
Cause: The destructor is then refactored before the parent class, because the parent pointer can point to the subclass object, such as:
void Main () { base* p =}
If the parent class is not a virtual function, the compiler will simply refactor the parent class, not the pipe class, thus causing the subclass memory to leak.
When the parent destructor is set to a virtual function, the compiler discovers that it is a virtual function, so it can be judged that the pointer is a subclass, and therefore the subclass and its parent are broken down.
Constructors and destructors