Excerpt from the Houtie version of effective C + + (third edition)Clause IC + + as a multi-paradigm fusion language, can be seen as a language of the Commonwealth, it contains the four major sub-languages:
C. C + + is based on, many times C + + for the problem of the solution is actually higher-level C solution, but the C language limitations: No template, no exception handling, no overloading.
OO C + +. Includes classes, encapsulation, i
Chapter Review:The 1th chapter of effective C + + makes himself accustomed to c++-reading notesEffective C + + 2nd structure/destructor/assignment operation (1)-Reading notesEffective C + + 2nd structure/destructor/assignment operation (2)-Reading notes"Effective C + +" Chapter 3rd resource Management (1)-Reading notes"Effective C + +" 8th custom new and delete-r
Chapter One make yourself accustomed c++accustoming yourself to C + +Article 01: Treat C + + as a language federalView C + + as a federation of LanguagesAt first C + + was just a few object-oriented features, but as the language matured, it began to accept various concepts, features, and strategies that differed from C with classes. Exception brings different approaches to the structuring of functions, templates introduces a new way of designing thinking, and
tem1) {return CTest (tem0. GetValue () * tem1. GetValue ());} CTest Test0 (1); CTest Test1 = Test0 * 2;//allowed by compiling//ctest Test2 = 2 * test0;//not allowed by compile//reason ctest Test1 = Test0 * 2; can be compiled because an implicit type conversion occurs, converting 2 to CT EST type//the reason ctest Test2 = 2 * TEST0; cannot be compiled because only the arguments are in the parameter list, this parameter can only occur implicitly type conversions. CTest Test2 = Funtest (2, 2);//al
article 01: treat C + + as a language federalto better understand C + +, we decompose C + + into four major sub-languages:
C in the final analysis C + + is still based on C. chunks, statements, pre-processor, built-in data types, arrays, pointers all from C.
object-oreinted C + + This part is the most direct implementation of the classical code of object-oriented design in C + +. classes, encapsulation, inheritance, polymorphism, virtual functions, etc...
Template C + + This is
IntroductionIn my last blog, I spoke about the swap function.The swap is only part of the STL and then becomes the spine of an unusually safe program, and is used to handle the possibility of self-assignment.One, swap functionThe swap function of the standard library is as follows:1 namespace STD {2 template3 void swap (T a, t b) 4 {5 T Temp (a); 6 A = b; 7 b = temp; 8 }9 }As long as the type T suppor
Effective C # principle 1: Use attributes (property) as much as possible, rather than data members (field)
Effective C # principle 2: Choose ReadOnly instead of const for your constants
Effective C # Principle 3: Select is or as operator instead of coercion type conversion
Effective C # principle 4: precompiling blo
STL contains methods used to iterate elements in containers-iteration methods, including for_each, transform, copy, find, remove
1. Usage:
// Template function, print element
2. Details
How to Implement for_each? Below is the source code of STL (excluding some diagnostic code)
// Template function for_each
We can see that every element in the iteration container is used as a parameter to call the third p
Template is a good thing. Classic STL. powerful boost.
Dynamic Link is also a good thing. It is called DLL in windows and so (Share Object) in Unix. It can save a lot of trouble for software re-release.
However, when a template encounters a dynamic link, it is often a nightmare.Now let's talk about some of the problems I have encountered. The problems are mainly focused on memory allocation.1>For STL, it is
Anti-DDoS program module indirectly transmits STL instance objects through struct
We often pass parameters to functions through struct. In principle, the struct should not contain non-pod members.
[Reference]========================================================== ==========================================Pod, short for plain old data, a common old data structure (POD) is a data structure. It is used only as the field value of passive favorites, and
STL provides many generic containers, such as vector, list, and map. When using these containers, programmers only need to worry about when to plug objects into the container, instead of how to manage the memory and how much memory is needed. These STL containers greatly facilitate the compilation of C ++ programs. For example, you can use the following statement to create a vector, which is actually an on-
Clause 38: design the imitation function class for value transfer
Neither C ++ nor C ++ allows you to pass functions as parameters to other functions. Instead, you must passPointerTo the function. For example, here is a declaration of the standard library function qsort:
void qsort(void *base, size_t nmemb, size_t size, int (*cmpfcn)(const void*, const void*));
Cla46 explains why the sort algorithm is generally a better choice than the qsort function, but it is not a problem here. The problem
Finally, I have the opportunity to have the motivation to view jjhou's STL source code parsing. It is expected that the entire book will be read in the fast-reading mode. The underlying mechanisms of map and set are RB-Tree (red-black Tree), and insertion and search are O (lgN) complexity. Map and set have been heard before, but they are never used, because they do not know what is behind them. I read this book to learn about it.
Finally, I have the
1. Why to build STL: The improvement of the reusability of the program (based on the standard)2, the value of STL:1) STL brings the most useful components2) "Taxonomy of software Components" based on generic thinking3, a sentence summed up the STLSTL implements an interface standard that is based on an abstract conceptual framework.Under this interface, any compo
Incomplete list of STL technical articles (STL learning User Guide)
Standard Template Library (STL) Introduction (I) Local stickers
This article uses the list container as an example to introduce the basic content of STL, from the container to the iterator, and then to the common functions. The examples are rich and
STL, Standard Template Library, is the implementation of C + + for generic programming ideas, which was first developed by HP Labs. This technology has existed for a long time before being introduced to C + +. Later STL became part of the Ansi/iso C + + standard. Each C + + vendor also has its own template library, which may be highly efficient, but portability is not necessarily good.In the C + + standard,
0 Preface: STL, why do you have to master
For programmers, data structures are a compulsory subject. From the search to the sort, from the list to the two fork tree, almost all algorithms and principles need to understand, can not understand also to memorize. Fortunately, these theories have been more mature, the algorithm is also basically fixed, do not need to spend your mind to consider the principle of its algorithm, and no longer to verify its a
Hou Jie said: Tracking first-class programs, absorbing nutrients from them, and imitating the programs he wrote are much more valuable than the third-stream programs that he thinks he is trying to write, at least I think so-99.999% of the world's programs are at the bottom of the three streams in front of STL!
Mr Hou Jie's comment on STL is too high. He used to be familiar with
Simplified STL (Chinese)
Author: winter
He said that for STL, programmers have three realms: using STL, understanding STL, and adding STL. Negative STL is a very good book that helps you better understand
STL Learning 1: Theoretical Basis of the standard template library,
STL (Standard Template Library) is a collection of software developed by the HP lab. This technology has been around for a long time before it was introduced into C ++.
In a broad sense, STL is divided into three types: algorithm (algorithm), container (container), and iterator (iterator). contai
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.