Skip to content

Add missing header files #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion book/en-us/01-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Don't worry at the moment, we will come to meet them in our later chapters.
## Further Readings

- [A Tour of C++ (2nd Edition) Bjarne Stroustrup](https://www.amazon.com/dp/0134997832/ref=cm_sw_em_r_mt_dp_U_GogjDbHE2H53B)
- [C++ History](http://en.cppreference.com/w/cpp/language/history)
[History of C++](http://en.cppreference.com/w/cpp/language/history)
- [C++ compiler support](https://en.cppreference.com/w/cpp/compiler_support)
- [Incompatibilities Between ISO C and ISO C++](http://david.tribble.com/text/cdiffs.htm#C99-vs-CPP98)

Expand Down
9 changes: 9 additions & 0 deletions book/en-us/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ such as:

```cpp
#include <initializer_list>
#include <vector>
class MagicFoo {
public:
std::vector<int> vec;
Expand Down Expand Up @@ -342,6 +343,7 @@ and the structured bindings let us write code like this:

```cpp
#include <iostream>
#include <tuple>

std::tuple<int, double, std::string> f() {
return std::make_tuple(1, 2.3, "456");
Expand Down Expand Up @@ -776,6 +778,7 @@ how to unpack the parameters?
First, we can use `sizeof...` to calculate the number of arguments:

```cpp
#include <iostream>
template<typename... Ts>
void magic(Ts... args) {
std::cout << sizeof...(args) << std::endl;
Expand Down Expand Up @@ -919,6 +922,7 @@ C++11 introduces the concept of a delegate construct, which allows a constructor
in a constructor in the same class, thus simplifying the code:

```cpp
#include <iostream>
class Base {
public:
int value1;
Expand All @@ -943,6 +947,7 @@ int main() {
In traditional C++, constructors need to pass arguments one by one if they need inheritance, which leads to inefficiency. C++11 introduces the concept of inheritance constructors using the keyword using:

```cpp
#include <iostream>
class Base {
public:
int value1;
Expand Down Expand Up @@ -1091,6 +1096,10 @@ This section introduces the enhancements to language usability in modern C++, wh
1. Using structured binding, implement the following functions with just one line of function code:

```cpp
#include <string>
#include <map>
#include <iostream>

template <typename Key, typename Value, typename F>
void update(std::map<Key, Value>& m, F foo) {
// TODO:
Expand Down
4 changes: 4 additions & 0 deletions book/zh-cn/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ int main() {

```cpp
#include <initializer_list>
#include <vector>
class MagicFoo {
public:
std::vector<int> vec;
Expand Down Expand Up @@ -277,6 +278,7 @@ C++17 完善了这一设定,给出的结构化绑定可以让我们写出这

```cpp
#include <iostream>
#include <tuple>

std::tuple<int, double, std::string> f() {
return std::make_tuple(1, 2.3, "456");
Expand Down Expand Up @@ -823,6 +825,7 @@ int main() {
C++11 引入了委托构造的概念,这使得构造函数可以在同一个类中一个构造函数调用另一个构造函数,从而达到简化代码的目的:

```cpp
#include <iostream>
class Base {
public:
int value1;
Expand All @@ -847,6 +850,7 @@ int main() {
在传统 C++ 中,构造函数如果需要继承是需要将参数一一传递的,这将导致效率低下。C++11 利用关键字 using 引入了继承构造函数的概念:

```cpp
#include <iostream>
class Base {
public:
int value1;
Expand Down