The Declaration sequence and structure sequence of the member variables in MFC, and the declaration of the mfc member variables
I used my blog for the first time and wrote the first article casually. Let's write a question that I encountered today.
In the MFC Dialog Box program of VS2008, the Declaration Order of window member variables is the opposite to that of window member variables. That is, the Declaration result is the declaration result and the declaration result is the first analysis result. Not tested in other modes.
Class A {public: A () {MessageBox (NULL, "A constructor", "A", MB_ OK );}~ A () {MessageBox (NULL, "A destructor", "A", MB_ OK); // the dialog box is not displayed.}; class B {public: B () {MessageBox (NULL, "B constructor", "B", MB_ OK );}~ B () {MessageBox (NULL, "B destructor", "B", MB_ OK); // the dialog box is not displayed }};
Then declare the variable in the dialog box class.
A a; B B;
Run the program. The "A constructor" dialog box appears, and the "B constructor" dialog box appears.
Close the program. After debugging, you can find that the "B destructor" dialog box is called first, and then the "A destructor" dialog box is called. But in fact these two dialogs do not appear, probably because the program exits, and MFC stops the window pop-up.
Conclusion: The declared variables are parsed first, and then declared variables are parsed first.
This is often useful when A and B are coupled. For example, B uses A member. If A first analyzes the structure and B's thread has not exited, overflow may occur, or the exit of the dialog box interface but the process has not ended.