<Effective C++>读书摘要--Introduction

Introduction

1、Learning the fundamentals of a programming language is one thing; learning how to design and implement effective programs in that language is something else entirely.

想起<重构>里面说的一句话,写出计算机能理解的代码很容易,但是写好人能理解的代码不容易

2、A declaration tells compilers about the name and type of something, but it omits certain details.

3、Initialization is the process of giving an object its first value.

4、Constructors declared explicit are usually preferable to non-explicit ones, because they prevent compilers from performing unexpected (often unintended) type conversions. Unless I have a good reason for allowing a constructor to be used for implicit type conversions, I declare it explicit.

explicit 关键字限制不能进行隐式转换

5、The copy constructor is used to initialize an object with a different object of the same type, and the copy assignment operator is used to copy the value from one object to another of the same type

 1 class Widget {
 2 public:
 3 Widget();    // default constructor
 4 Widget(const Widget& rhs);     // copy constructor
 5 Widget& operator=(const Widget& rhs);    // copy assignment operator
 6 ...
 7 };
 8 Widget w1;     // invoke default constructor
 9 Widget w2(w1);     // invoke copy constructor
10 w1 = w2;     // invoke copy assignment operator</span>
11 Widget w3 = w2; // invoke copy constructor!</span>

pass by value 的时候使用的是copy constructor

6、undefined behavior:编译器不确定行为,如数组越界访问,dereference一个空指针等

7、When I use the term "interface," I'm generally talking about a function's signature, about the accessible elements of a class (e.g., a class's "public interface," "protected interface," or "private interface"), or about the expressions that must be valid for a template's type parameter (see Item 41).

8、A client is someone or something that uses the code (typically the interfaces) you write.

9、Two of my favorite parameter names, for example, are lhs and rhs. They stand for "left-hand side" and "right-hand side," respectively.

10、I often name pointers following the rule that a pointer to an object of type T is called pt. I use a similar convention for references: rw might be a reference to a Widget and ra a reference to an Airplane. I occasionally use the name mf when I'm talking about member functions.

11、As a language, C++ has no notion of threads — no notion of concurrency of any kind, in fact.

12、TR1 ("Technical Report 1") is a specification for new functionality being added to C++'s standard library.This functionality takes the form of new class and function templates for things like hash tables, reference-counting smart pointers, regular expressions, and more. All TR1 components are in the namespace tr1 that's nested inside the namespace std.

13、Boost is an organization and a web site (http://boost.org) offering portable, peer-reviewed, open source C++ libraries. Most TR1 functionality is based on work done at Boost, and until compiler vendors include TR1 in their C++ library distributions, the Boost web site is likely to remain the first stop for developers looking for TR1 implementations. Boost offers more than is available in TR1, however, so it's worth knowing about in any case.



原文地址:https://www.cnblogs.com/lshs/p/4396884.html