文章的后半部分提供中文的简版.

Chapter 1 The Basics

Which two are defined by The ISO C++ standard?

  • Core language features, such as built-in types (e.g., char and int) and loops (e.g., for-statements and while-statements)
  • Standard-library componets, such as containers (e.g. vector and map) and I/O operations(e.g., << and getline())

The standard-library componets are perfectly ordinary C++ code provided by every C++ implementations. That is, the c++ library can be implemented in C++ itself and is (with very minor use of machine code for things such as thread context switch).

C++ is a statically typed language,or dynamic?

c++ is a statically typed language. That is, the type of every entity(e.g., object, value, name and expression) must be known to the complier at its point of use(at compiler time). Dynamic programming language in computer science is a class of high-level programming languages, which at runtime, execute many common programming behaviours that static programming languages perform during compilation.

Three tasks of function declaration

  1. A function declaration gives the name of the function
  2. the type of the value returned (if any)
  3. and the number and types of the arguments that must be supplied in call.

How to write comprehensible code?

We want our code to be comprehensible, because that is the first step on the way to maintaionability.

  • The first step to comprehensibility is to break computational task into meaningful chunks (represented as funcations and classes) and name those.
  • The number of errors in code correlates strongly with the amount of code and the complexity of the code. Both problems can be addressed by using more and shorter functions.

recommend link: Six ways to write more comprehensible code

What is th function overloading? Why Python/Golang not supurted function overload

If two funcitons defined with the same same, but with different argument type, the complier will choose the most approprite function to invoke for each call. For example:

void print(int);     // takes an integer argument
void print(double);  // takes a floating-point argument
void print(string);  // takes a string argument

void user()
{
     print(42);               // calls print(int)
     print(9.65);             // calls print(double)
     print("Barcelona");      // calls print(string)
}

ISO C++标准定义的哪两种实体?

  • 核心语言特性, 比如内建类型, char和int, 和循环, 比如for和 while循环
  • 标准库组件, 比如容器类型, vector, map, I/O操作

其中标准库都是很普通的C++实现, 也就是说, C++的标准库可以由C++自身实现, 以及少量的机器码(比如线程上下文切换).

C++是静态类型语言,还是动态类型语言?

静态类型.编译器必须知道每个实体的类型.

函数声明的作用

  1. 给定函数的名字
  2. 指出返回值的类型
  3. 表明函数的类型和参数个数

如何写出易于理解的代码

  1. 拆分成若干个模块(函数和类的形式),给每个模块起个通俗易懂的名字.
  2. 多使用简短的函数,有助于降低代码的规模和复杂成都