Item 43: Learn how to access names in templatized base classes (templated base class)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
Suppose we want to write an application that can send messages to several different companies. Messages can be transmitted in either encrypted or plaintext (not encrypted) mode. If we have enough information to determine which message will be sent to which compan
Item 46: non-member functions (non-member functions) are defined in the templates (Template) When type conversions is required)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
Item 24 explains why only non-member functions (non-member functions) are suitable for implicit type conversions (implicit type conversion) applied to all arguments (real parameters ), it also serves as an example to use
Item 11: Processing assignment to self in operator = (Auto assigned)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
When an object is assigned to itself, assignment to self occurs ):
Class widget {...};
Widget W;...
W = W; // assignment to self
This looks silly, but it is legal, so be sure the customer will do so. In addition, assignment (Value assignment) is not always so easy to identify.
Item 8: prevents Destructors (destructor) from being removed due to exceptions)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
C ++ does not prohibit the triggering of exceptions (Exceptions) from Destructors, But it resolutely blocks such practices. For any good reason, consider:
Class widget {Public:...~ Widget () {...} // assume this might emit an exception};
Void dosomething (){STD: vector
semantics of values. If a value type is large, performance problems may occur when passing parameters and function return values.
With regard to article 1st, Bill Wagner mentioned in this clause that "reference types impose a burden on the garbage collector" is a seemingly correct judgment. However, due to the box/Unbox effect, in some cases, the value type has brought more burden to the garbage collector. For example, you can place some value types in a collection and then perform read/w
more information on this topic, see also Scott Meyers section, "never treat arrays polymorphically" in meyers99. Guideline
Never treat arrays polymorphically.
Guideline
Prefer usingVector OrDeque Instead of arrays.
Are the following two assignments legal?typedef void (B::*PMF)(void*, size_t); PMF p1 = B::f; PMF p2 = B::operator delete;The first assignment is fine; we're re simply a
In tr1 of C ++ (TechnologyReport) contains a function template class and bind template function. They can be used to implement functions similar to function pointers, but they are more flexible than function pointers.. See Scott Meyers. Item 35. The following describes how to use it.
1. When pointing to a global function or a static member function
In essence, global functions and static member functions are not partitioned.No. In terms of usage,
essentially an alarm and has the door function, then the above definition method will be reversed.
Back to Top
Conclusion
Abstract class and interface are two methods of defining abstract classes in Java. They have great similarity. However, their choices often reflect the understanding of the essence of concepts in the problem field, and whether the reflection of design intent is
pitfallsTitle (Chinese): c traps and DefectsOld Andrew Koenig
7. C ++ (C ++)
Title: C ++ primer, Third Edition Forth editionTitle (Chinese): c ++ primer (third and fourth editions)Original Stanley B. Lippman/Jos é e Lajoie/Barbara E. MooTranslators: Li shixian, Jiang Aijun, Mei Xiaoyong, Lin Yu
In all fairness, the third edition of this book is not suitable for entry, but the fourth edition is suitable. So the emergence of the fourth version does not mean that the third version will lose its
C/C ++ recommended books:C ++ programming language Bjarne stroustrup)C ++ primer (version 4) Stanley B. Lippman, Joseph Lajoie (for reference)C ++ programming specifications: 101 rules, guidelines and best practices herbsutter, Andrei Alexandrescu 2006 (more) Exceptional C ++ herbsutter 2006(More) Valid tive C ++ Scott Meyers 2006Predictional C ++ style: 40 new engineering challenges, Programming Problems and Solutions herbsutter 2006C ++ templates Da
Finally, I found the complete Chinese version of objective STL and gave it to everyone.The author explains how to combine STL components to maximize the benefits of library design. This information allows you to develop simple and direct solutions for simple and direct problems, and helps you design elegant methods for more complex problems. I described common STL usage errors and showed you how to avoid them. This helps you avoid transient resource leaks, unportable code, and undefined behavior
timeM_instanceAllocate and initialize the memory.It seems that all the problems have been solved, and the initialization sequence is ensured, and there is no problem with polymorphism. however, you may have discovered a problem. When the program exits, the Destructor is not executed. this may cause resource leakage in some systems with unreliable design, such as file handles, socket connections, and memory. fortunately, common systems such as Linux, Windows 2000, and XP can automatically releas
point to this copy. This strategy is implemented in copied_ptr.h.
Ownership Transfer: Let both p and q point to the same object, but transfer the responsibility for cleaning up ("ownership") from P to Q. This strategy is implemented in owned_ptr.h.
Reference counting: Maintain a count of the smart pointers that point to the same object, and delete the object when this count becomes zero. so the statement q = P causes the count of the object pointed by P to increase by one. this strategy is im
bookmarks. Alt + Pageup and ALT + Pagedown can be used to switch between bookmarks.• Ctrl + Shift + B to find matching parentheses.• When looking at the long code, you can right-click and select folding-> fold all. Then, you can take full advantage of the symbol browser in the management column on the left.• Right-click a variable, function, or macro, and select three menu items starting with "find, you can go to its declaration, definition, and find all the places where it appears (Press f2 to
delete operation is the cached ITER (that is, the current ITER (the ITER after the add operation) point to the previous node ).According to the above analysis, we can see that mapstudent. Erase (ITER ++) and MAP student. Erase (ITER); ITER ++; the execution sequence is different. The former performs the add operation before erase execution and before ITER is deleted (invalid). The latter performs the add operation only after erase execution, at this time, the ITER has been deleted (the current
Item 29: Get exception-safe code (abnormal security code)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
Exception safety (abnormal security) is a bit like pregnancy (pregnant )...... However, keep this idea for a while. We cannot really talk about reproduction until we have exclusive to courtship ). (The three words used by the author in this section have dual meanings. Pregnancy can also be
Item 24: When you want to apply type conversions (type conversion) to all parameters (parameters), declare it as non-member functions (non-member function)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
In the book's introduction (Introduction), it is often a bad idea to allow classes to support implicit type conversions (implicit type conversion. Of course, this rule has an exception. The most
Item 3: Use const whenever possible
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
One wonderful thing about const is that it allows you to specify a semantic (semantic) Constraint: a specific object (object) should not be modified. The compilers (compiler) will execute this constraint. It allows you to notify compilers (compiler) and other programmers that a value should remain unchanged. If th
Item 4: Make sure that the objects (object) is initialized before use
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
C ++ seems unpredictable in the initialization of object values. For example, if you do this,
Int X;
In some cases, X is initialized (0), but it may not exist in other cases. If you do this,
Class Point {Int X, Y;};
...
Point P;
P's data members (data members) are sometimes init
Item 1: view C ++ as Federation of languages)
By Scott Meyers
Translator: fatalerror99 (itepub's nirvana)
Release: http://blog.csdn.net/fatalerror99/
Initially, C ++ only added some object-oriented (Object-Oriented) features on the basis of C. The original name of C ++ -- "C with classes" represents this very intuitively.
As a mature process of a language, C ++'s growth is bold and full of adventure. It absorbs ideas and features, so that programming
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.