Skip to content

Commit 0aa031f

Browse files
Delta456changkun
authored andcommitted
book: add missing header files (changkun#74)
1 parent 934eb89 commit 0aa031f

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

book/en-us/01-intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Don't worry at the moment, we will come to meet them in our later chapters.
138138
## Further Readings
139139

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

book/en-us/02-usability.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ such as:
286286

287287
```cpp
288288
#include <initializer_list>
289+
#include <vector>
289290
class MagicFoo {
290291
public:
291292
std::vector<int> vec;
@@ -342,6 +343,7 @@ and the structured bindings let us write code like this:
342343
343344
```cpp
344345
#include <iostream>
346+
#include <tuple>
345347
346348
std::tuple<int, double, std::string> f() {
347349
return std::make_tuple(1, 2.3, "456");
@@ -776,6 +778,7 @@ how to unpack the parameters?
776778
First, we can use `sizeof...` to calculate the number of arguments:
777779
778780
```cpp
781+
#include <iostream>
779782
template<typename... Ts>
780783
void magic(Ts... args) {
781784
std::cout << sizeof...(args) << std::endl;
@@ -919,6 +922,7 @@ C++11 introduces the concept of a delegate construct, which allows a constructor
919922
in a constructor in the same class, thus simplifying the code:
920923
921924
```cpp
925+
#include <iostream>
922926
class Base {
923927
public:
924928
int value1;
@@ -943,6 +947,7 @@ int main() {
943947
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:
944948
945949
```cpp
950+
#include <iostream>
946951
class Base {
947952
public:
948953
int value1;
@@ -1091,6 +1096,10 @@ This section introduces the enhancements to language usability in modern C++, wh
10911096
1. Using structured binding, implement the following functions with just one line of function code:
10921097
10931098
```cpp
1099+
#include <string>
1100+
#include <map>
1101+
#include <iostream>
1102+
10941103
template <typename Key, typename Value, typename F>
10951104
void update(std::map<Key, Value>& m, F foo) {
10961105
// TODO:

book/zh-cn/02-usability.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ int main() {
232232

233233
```cpp
234234
#include <initializer_list>
235+
#include <vector>
235236
class MagicFoo {
236237
public:
237238
std::vector<int> vec;
@@ -277,6 +278,7 @@ C++17 完善了这一设定,给出的结构化绑定可以让我们写出这
277278
278279
```cpp
279280
#include <iostream>
281+
#include <tuple>
280282
281283
std::tuple<int, double, std::string> f() {
282284
return std::make_tuple(1, 2.3, "456");
@@ -823,6 +825,7 @@ int main() {
823825
C++11 引入了委托构造的概念,这使得构造函数可以在同一个类中一个构造函数调用另一个构造函数,从而达到简化代码的目的:
824826

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

0 commit comments

Comments
 (0)