The first time to study one months, read the "Big Talk design mode" and "Effective C + +" two books, the first half of the two books are relatively easy, but later parts, such as: C + + memory, exception and template knowledge is difficult to understand. It may be that you rarely use exception handling and template relationships with yourself. I insisted on one months, anyway, these two books brought me a lot of new knowledge, found their shortcomings. Next, I intend to continue to read the "C + + Templates" This book, hope to make up for their own templates in the ease of programming and for the future study of STL and boost to lay a solid foundation. Cut the crap and talk about it. Let's talk about the last point of the two books.
Visitor Mode (Visitor): Represents an operation that acts on elements in an object's structure. It allows you to define new actions that act on these elements without changing the class of each element.
(1), the visitor pattern is suitable for systems with relatively stable data structures.
(2), the visitor pattern frees up the coupling between the data structure and the operations acting on the structure so that the set of operations can evolve relatively freely.
(3), the purpose of the visitor pattern is to separate processing from the data structure.
(4), the visitor pattern is a bit more easy to add new operations, because adding new operations means adding a new visitor. The visitor pattern concentrates the behavior on a visitor object.
(5), the disadvantage of the visitor pattern is that it becomes difficult to add new data structures.
Effective C + +:
1: Need to stick to general when writing new and delete
(1), operator new should contain an infinite loop in which to attempt to allocate memory, and if it does not meet the memory requirements, the call New-handler. It should also be able to handle applications for 0 bytes. The class-specific version should also handle "applications larger than the correct size".
(2), operator delete should not do anything when a null pointer is received. The Class-specific version should handle "error requests that are larger than the correct size."
2: wrote placement new also to write placement delete
(1), when you write a placement operator new, make sure that the corresponding placement operator delete is also written. If you do not do this, your program may have a hidden crisis and a memory leak that is intermittent.
(2), when you declare placement new and placement Delete, make sure that you do not unconsciously obscure the normal version of them.
3: Do not easily ignore compiler warnings
(1) to seriously treat the warning message issued by the compiler. Try to get "no warning" at the highest warning level of your compiler.
(2), do not rely too much on the compiler's alarm ability, because different compilers treat things differently, once ported to another compiler, you originally relied on the warning message may disappear.
4: Familiarize yourself with the standard library including TR1
(1), the main function of C + + library consists of STL, iostreams and locales. and contains the C99 standard library.
(2), TR1 adds a smart pointer, a generalized function pointer, a hash-based container, a regular expression, and support for another component.
(3), TR1 itself is only a specification. To get the benefits of TR1, you need a physical one. A good in-kind comes from Boost.
5: Make yourself familiar with Boost
(1), Boost is a community and a website. Dedicated to free, open source, peer review of C + + library development. Boost plays a powerful role in the C + + standardization process.
(2), Boost offers many TR1 component implementations, as well as many other library applications.
Discover today:
Ncframelesshelper the use of QT internal events to achieve the top-level borderless form of drag-and-drop, mobile and other functions.
Issue: VLC and DirectX are affected by the top-level form Wa_translucentpaintevent property when they play the video and cannot be displayed. The right solution for the moment.