Obtain CWinApp:-Directly call AfxGetApp () or use theApp in CMainFrame, CChildFrame, CDocument, and CView-Only AfxGetApp () can be used in other classes ()
Obtain CMainFrame:-Use AfxGetMainWnd () or m_pMainWnd in CMinApp-GetParentFrame () is
1, reference base class object directly with base class pointer2, referencing derived class objects directly with derived class pointers3, reference a derived class object with a base-class pointer, because the derived class object is also an object
in the degree Niang there found a cow man's answer, copied over http://zhidao.baidu.com/link?url=AhjH4Os7ixE7gzWxChCLyd13yQGdb47dAbSm_p1BsyKmh4_ _qlctwornkwig5x9ksdg4tymasp1syknrf47odqVirtual functions in C + + While it is difficult to find a C + +
Features of member functions being overloaded:(1) the same range (in the same class );(2) The function name is the same;(3) parameters are different;(4) virtual keywords are optional.Override refers to the function of a derived class that overwrites
Access other classes of the applicationObtain cwinapp:-Directly call afxgetapp () or use theapp in cmainframe, cchildframe, cdocument, and cview-Only afxgetapp () can be used in other classes ()Obtain cmainframe:-Use afxgetmainwnd () or m_pmainwnd
The access between documents, views, and frameworks in MFC has been a common topic, but I don't think there are any detailed descriptions.
For those with poor English, I checked some blogs and summarized them! I hope it will be helpful to people
1) Get the doc pointer in the view2) obtain the mainframe pointer in the app3) obtain the mainframe pointer in the view.4) obtain the view (created) pointer5) Get the pointer to the current document6) Get the status bar and toolbar
As long as the base class has declared the Virtue keyword when defining a member function, when overridden by a derived class, the Virtue keyword can be added without affecting the implementation of the polymorphic.Easy to confuse with
The theoretical premise of virtual destructor isAfter executing the destructor of the subclass, the fictitious function of the parent class is bound to be executed.Then when you use Delete to release a subclass object that is instantiated by a
Original address: http://www.vckbase.com/index.php/wv/459
1) Get doc pointer in view2) Get mainframe pointer in app3) Get mainframe pointer in view4) Get the view (established) pointer5) Get the current document pointer6) Get the
# Include Class A {int A; public: A (int x): A (x) {cout B(int v): b(v),y(b+2),x(b+1), d(b),A(v){ c=v; cout What does this code output?1 first a (v) is 12 a x: 23 a y: 34 B (INT V): 1 1 1 c5 ~ B (): d6 A y analysis structure:
1) Get the doc pointer in the view
2) obtain the mainframe pointer in the app
3) obtain the mainframe pointer in the view.
4) obtain the view (created) pointer
5) Get the pointer to the current document
6) Get the status bar and toolbar pointer
7)
The type conversion under polymorphism is used for a question in the exercise class for freshman students. For the type conversion of multi-state inheritance, there are two types of conversion: upcast and downcast. The difference between the two
Virtual functions are an important concept in Object-Oriented C ++. Because it fully embodies the inheritance and polymorphism features in object-oriented thinking, it is widely used in C ++. For example, in Microsoft's MFC class library, you will
Assigning values between a base-class pointer and a child-class pointer(1) When assigning a subclass pointer to a base class pointer, no forced type conversion is required, and the C + + compiler automatically casts the type. Because the child class
Four types of coercion for C + + are converted to: static_cast, Const_cast, reinterpret_cast, and dynamic_cast
General form of type conversion: Cast-name
Static_castAny explicitly defined type conversions can use static_cast as long as
C + + When the member function of a subclass has the same name as the member function of the parent class:If the parent class does not have a virtual declaration, the subclass function can be different from the parent class function return value,
1, sometimes, the function of many parameters, it is best to also line , such as:CreateProcess (NullCmdbuf,NullNullBINHH,Dwcrtflags,Envbuf,Null&sistartinfo,&prinfo);The number of parameters of the function is best not too much, generally speaking 6
You can let member function operations generalize, with pointers to the base class pointing to objects of different derived classes,When a base-class pointer calls its virtual member function, it calls the member function that actually points to the
Methods for obtaining other class pointers in the MFC window
Source: China self-learning Programming Network Release Date: 2008-09-26
Obtain CWinApp:-Directly call AfxGetApp () or use theApp in CMainFrame, CChildFrame, CDocument,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.