<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
class Widget {
public:
Widget(); // default constructor
Widget(const Widget& rhs); // copy constructor
Widget& operator=(const Widget& rhs); // copy assignment operator
...
};
Widget w1; // invoke default constructor
Widget w2(w1); // invoke copy constructor
10 w1 = w2; // invoke copy assignment operator</span>
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.
<Effective C++>读书摘要--Introduction的更多相关文章
- <Effective C++>读书摘要--Designs and Declarations<一>
<Item 18> Make interfaces easy to use correctly and hard to use incorrectly 1.That being the c ...
- <Effective C++>读书摘要--Inheritance and Object-Oriented Design<一>
1.Furthermore, I explain what the different features in C++ really mean — what you are really expres ...
- <Effective C++>读书摘要--Implementations<二>
<Item29> Strive for exception-safe code. 1.如下面的代码 class PrettyMenu { public: ... void changeBa ...
- <Effective C++>读书摘要--Implementations<一>
1.For the most part, coming up with appropriate definitions for your classes (and class templates) a ...
- <Effective C++>读书摘要--Accustoming Youself to C++
<Item 1>View C++ as a federation of languages. 1.把C++看成4种子语言组成,即C.Object-Oriented C++.Template ...
- <Effective C++>读书摘要--Templates and Generic Programming<一>
1.The initial motivation for C++ templates was straightforward: to make it possible to create type-s ...
- <Effective C++>读书摘要--Inheritance and Object-Oriented Design<二>
<Item 36> Never redefine an inherited non-virtual function 1.如下代码通过不同指针调用同一个对象的同一个函数会产生不同的行为Th ...
- <Effective C++>读书摘要--Designs and Declarations<三>
<Item 22> Declare data members private 1.使数据成员private,保持了语法的一致性,client不会为访问一个数据成员是否需要使用括号进行函数调 ...
- <Effective C++>读书摘要--Designs and Declarations<二>
<Item 20> Prefer pass-by-reference-to-const to pass-by-value 1.By default, C++ passes objects ...
随机推荐
- MySQL5.7主从同步--点位方式及GTID方式
MySQL5.6加入了GTID的新特性,其全称是Global Transaction Identifier,可简化MySQL的主从切换以及Failover.GTID用于在binlog中唯一标识一个事务 ...
- buck型DC-DC分析
BUCK型DC/DC电源分析 这种buck型DC/DC电路的拓扑结构:( 1N5822叫续流二极管!) LM2756相当于高速断开和闭合的开关,连接在Vin与Vout脚之间. 1. 在开关闭合时,电流 ...
- gem install tiny_tds失败
解决: brew install freetds gem install tiny_tds -v '2.1.0'
- Linux字符设备驱动--No.2
分析中断注册函数:request_irq int butsOpen(struct inode *p, struct file *f) { int irq; int i; ; printk(KERN_E ...
- 小程序开发-10-新版Music组件、组件通信与wxss样式复用
加入缓存提升用户体验 思路:先从缓存中寻找数据或者从服务器中获取数据写入缓存中 优点:减少网络访问次数,提升用户体验 解决缓存带来的问题 问题:比如原先是不喜欢的在点击喜欢的时候,跳到下一期刊后返回来 ...
- 棋盘覆盖(我们学校自己的UOJ上的变形题)
题目 #include<iostream> #include<cstring> #include<cstdlib> #include<cstdio> # ...
- MySQL高级第二章——索引优化分析
一.SQL性能下降原因 1.等待时间长?执行时间长? 可能原因: 查询语句写的不行 索引失效(单值索引.复合索引) CREATE INDEX index_user_name ON user(name) ...
- Java设计模式(14)——行为模式之不变模式(Immutable)
一.概述 概念 分类:弱不变模式(子类可变)和强不变模式(子类也是不可变) 应用场景 java.lang.String是一个经典的强不变类 二.分析 与享元模式的关系
- BZOJ1800_fly飞行棋_KEY
题目传送门 看数据范围,N<=20! 你没看错,搜索都能过. O(N^2)的做法,就是先求出有几对点之间的距离为圆周长的一半. 然后求C(N,2)即可. code: /************* ...
- tarjan算法求最近公共祖先
tarjian算法 LCA: LCA(Least Common Ancestor),顾名思义,是指在一棵树中,距离两个点最近的两者的公共节点.也就是说,在两个点通往根的道路上,肯定会有公共的节点,我们 ...