From WTL to MFC (1) ATL basic
Published on| April 29th, 2009 | No Comment.
Categories:WTL |
Description: WTL Environment, wrote in the articles below. So, WTL and I really want to treat.
Before that, WTL on mechanisms, ATL is a need for some level of understanding. Therefore a good article (See article below) that there are, help them a little, ATL and deepen their understanding.
Subject of this article, MFC with WTL programmers are those who are interested.
If you are fluent in English, you might be able to sense if you read the referenced article. (This article contents is almost similar to those in English. )
Articles Preferences: ResEdit (resources editor) and VC + + 2008 Exp. To be linked to
Articles: VC + + 2008 Express to compile the sample using WTL and Preferences
Articles: WTL for MFC Programmers, Part I - ATL GUI Classes
Sample source code you used here:
Articles: VC + + 2008 Express to compile the sample using WTL and Preferences
Articles: WTL for MFC Programmers, Part I - ATL GUI Classes
Sample source code you used here:
Features of ATL
MFC's programmer, ATL features of novelty,
- Virtual functions are used more safely using a template
Now the difference is, I see differences in the source code.
(This is the source code, public domain are diverted to see what the article is provided)
|
1.MFC way of inheritance, such as
|
2.ATL way of inheritance, such as
|
This output (behavior) is the same.
Above, like an inheritance in the MFC, ATL is a like inheritance.
What is the difference between 1,2,
- 1, using a virtual function. 2 is not used.
- 1, the normal B1-> D1, D2 inheritance. 2, B1, and while the base, B1 template parameter, D1, D2 are using it.
In other words, we can achieve the same way that creates a virtual function with a template.
- That is, 2, the virtual function table is not needed at run time, you reduce the consumption of the memory effect.
In addition, line 14 uses a static_cast.
- That is, 2, and type checking at compile time, there are safer and more effective handling.
I inherited this, weight, and carried over to the weight, please imagine a more complex and when multiple inheritance. This, ATL / WTL secret is that it is a light one, I can imagine.
Referenced in the article, "Benefits of the technique" is reported.
- Object (ie it is dynamically assigned a virtual function) does not require a pointer.
- vtbls is no need, you can save as much memory.
- That has not been initialized with a NULL vtbl runtime virtual function call using the pointer is virtually impossible.
- We have decided to compile a function call at all, and they are already optimized.
Pages: 1 2
You might also like:
Trackback URL
After Admin approves this comment, it will be shown.
Comments
Leave a Reply
