Effective C++ Item 1:View C++ as a federation of languages
笔记整理:邵盛松
Chapter 1:Accustoming Yourself C++
Item 1:View C++ as a federation of languages.
C. Way down deep, C++ is still based on C. Blocks, statements, the preprocessor, built-in data types, arrays,
pointers, etc., all come from C. In many cases, C++ offers approaches to problems that are superior to their C
counterparts (e.g., see Items 2 (alternatives to the preprocessor) and 13 (using objects to manage resources)), but
when you find yourself working with the C part of C++, the rules for effective programming reflect C's more limited
scope: no templates, no exceptions, no overloading, etc.
Object-Oriented C++. This part of C++ is what C with Classes was all about: classes (including constructors and
destructors), encapsulation, inheritance, polymorphism, virtual functions (dynamic binding), etc. This is the part of
C++ to which the classic rules for object-oriented design most directly apply.
Template C++. This is the generic programming part of C++, the one that most programmers have the least experience
with. Template considerations pervade C++, and it's not uncommon for rules of good programming to include special
template-only clauses (e.g., see Item 46 on facilitating type conversions in calls to template functions). In fact,
templates are so powerful, they give rise to a completely new programming paradigm, template metaprogramming (TMP).
Item 48 provides an overview of TMP, but unless you're a hard-core template junkie, you need not worry about it. The
rules for TMP rarely interact with mainstream C++ programming.
The STL. The STL is a template library, of course, but it's a very special template library. Its conventions
regarding containers, iterators, algorithms, and function objects mesh beautifully, but templates and libraries can
be built around other ideas, too. The STL has particular ways of doing things, and when you're working with the STL,
you need to be sure to follow its conventions.
Rules for effective C++ programming vary, depending on the part of C++ you are using
大意
文中主要描述如何理解C++语言
将C++ 看做是一个语言的联合,而不是某一单一语言。分为4个次语言
1 C。C++是以C为基础的,C++来自C的包括区块,语句,预处理器,内置数据类型,数组,指针等。
2 Object-Oriented C++。这部分就是常说的带类的C,类包括封装,继承,多态,虚函数等。
3 Template C++. 这是C++ 泛型编程,多数的程序员对这块经验较少。
4 STL 也就是标准模板库 包括容器,迭代器,算法,以及函数对象。常用的数据结构和算法都已经实现,封装成一个库,使用的时候
直接调用就行。
C++ 高效编程守则是根据你使用C++哪个部分而变化。
单词:
effective
adj. 有效的,起作用的;实际的,实在的;给人深刻印象
Accustom
vt. 使习惯于等
regardless
adj. 不管;不顾;不注意
enormous
adj. 庞大的,巨大的;凶暴的,极恶的
harness
vt. 披上甲胄;套;驾驭;治理
n. 马具;甲胄;挽具状带子;降落伞背带
fundamental
adj. 基本的,根本的
n. 基本原理;基本原则
[ 比较级more fundamental 最高级most fundamental ]
federation
n. 联合;联邦;联盟;联邦政府
tack
n. 大头钉;粗缝;行动方针;食物
vt. 附加;以大头针钉住
vi. 抢风航行;作文字形移动