fix #5, solve image not show up issue
9
.gitignore
vendored
@@ -32,7 +32,10 @@
|
||||
|
||||
node_modules
|
||||
|
||||
pdf/zh-cn/*.md
|
||||
|
||||
website/db.json
|
||||
website/public
|
||||
website/src/modern-cpp/book
|
||||
website/src/modern-cpp/images/cover-2nd.png
|
||||
website/public/*
|
||||
website/src/modern-cpp/book/*
|
||||
website/src/modern-cpp/assets/cover-2nd.png
|
||||
website/src/modern-cpp/assets/figures/*
|
||||
@@ -42,11 +42,13 @@
|
||||
|
||||
本书每章最后还加入了少量难度极小的习题,仅用于检验你是否能混合运用当前章节中的知识点。你可以在[这里](exercises)找到习题的答案,文件夹名称为章节序号。
|
||||
|
||||
## 本书网站
|
||||
|
||||
本书的[网站](https://changkun.de/modern-cpp)源码可以在[这里](./website)找到,由 [hexo](https://hexo.io) 和 [vuejs](https://vuejs.org) 协同构建而成。网站旨在提供一个除 GitHub 之外的阅读方式,除了在桌面端访问之外,你也可以在移动端上阅读本书。
|
||||
|
||||
## 致谢
|
||||
|
||||
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [issue](https://github.com/changkun/cpp1x-tutorial/issues)。并感谢以下读者指出本书中出现的错误:
|
||||
|
||||
[recolic](https://www.gitbook.com/@recolic), [sinomiko](https://www.gitbook.com/@sinomiko), [jackwish](https://www.gitbook.com/@jackwish), [asmwarrior](https://www.gitbook.com/@asmwarrior), [garicc](https://www.gitbook.com/@ihpy), [jiangwenhan](https://www.gitbook.com/@jiangwenhan), [liangx8](https://www.gitbook.com/@liangx8), [slivermeteor](https://github.com/slivermeteor), [inkedawn](https://github.com/inkedawn), [zhaoyao73](https://github.com/zhaoyao73), [sundy-li](https://github.com/sundy-li), [dontpanic92](https://github.com/dontpanic92), [axionl](https://github.com/axionl), [Rholais](https://github.com/changkun/modern-cpp-tutorial/commits?author=Rholais) [MikuGhoul](https://github.com/MikuGhoul), [coderall](https://github.com/coderall)
|
||||
笔者时间和水平有限,如果读者发现书中内容的错误,欢迎提 [issue](https://github.com/changkun/modern-cpp-tutorial/issues),或者直接提 [Pull Request](https://github.com/changkun/modern-cpp-tutorial/pulls)。由衷感谢每一位指出本书中出现错误的读者。
|
||||
|
||||
## 许可
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
@@ -51,7 +51,7 @@ InstalledDir: /Library/Developer/CommandLineTools/usr/bin
|
||||
|
||||
出于一些不可抗力、历史原因,我们不得不在 C++ 中使用一些 C 语言代码(甚至古老的 C 语言代码),例如 Linux 系统调用。在 C++1x 出现之前,大部分人当谈及『C 与 C++ 的区别是什么』时,普遍除了回答面向对象的类特性、泛型编程的模板特性外,就没有其他的看法了,甚至直接回答『差不多』,也是大有人在。图 1.2 中的韦恩图大致上回答了 C 和 C++ 相关的兼容情况。
|
||||
|
||||

|
||||

|
||||
|
||||
从现在开始,你的脑子里应该树立『**C++ 不是 C 的一个超集**』这个观念(而且从一开始就不是,后面的[进一步阅读的参考文献](#进一步阅读的参考文献)中给出了 C++98 和 C99 之间的区别)。在编写 C++ 时,也应该尽可能的避免使用诸如 `void*` 之类的程序风格。而在不得不使用 C 时,应该注意使用 `extern "C"` 这种特性,将 C 语言的代码与 C++代码进行分离编译,再统一链接这种做法,例如:
|
||||
|
||||
|
||||
@@ -168,11 +168,11 @@ int main() {
|
||||
|
||||
运行结果是 A, B 都不会被销毁,这是因为 a,b 内部的 pointer 同时又引用了 `a,b`,这使得 `a,b` 的引用计数均变为了 2,而离开作用域时,`a,b` 智能指针被析构,却智能造成这块区域的引用计数减一,这样就导致了 `a,b` 对象指向的内存区域引用计数不为零,而外部已经没有办法找到这块区域了,也就造成了内存泄露,如图所示:
|
||||
|
||||

|
||||

|
||||
|
||||
解决这个问题的办法就是使用弱引用指针 `std::weak_ptr`,`std::weak_ptr`是一种弱引用(相比较而言 `std::shared_ptr` 就是一种强引用)。弱引用不会引起引用计数增加,当换用弱引用时候,最终的释放流程如下图所示:
|
||||
|
||||

|
||||

|
||||
|
||||
在上图中,最后一步只剩下 B,而 B 并没有任何智能指针引用它,因此这块内存资源也会被释放。
|
||||
|
||||
|
||||
@@ -175,7 +175,7 @@ $endif$
|
||||
\noindent 本书系\href{https://github.com/changkun}{欧长坤}著,采用“知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议 (cc by-nc-sa)”进行许可。\texttt{\small http://creativecommons.org/licenses/by-nc-nd/4.0/}
|
||||
|
||||
\vspace{8em}
|
||||
\includegraphics{../assets/cover-2nd.png}
|
||||
\includegraphics{../../assets/cover-2nd}
|
||||
|
||||
\end{center}
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@ all:
|
||||
node install.js
|
||||
rm -rf src/modern-cpp/book
|
||||
python3 filter.py
|
||||
rm -rf ./src/modern-cpp/images/cover-2nd.png
|
||||
cp ../assets/cover-2nd.png ./src/modern-cpp/images/cover-2nd.png
|
||||
rm -rf ./src/modern-cpp/assets/cover-2nd.png
|
||||
rm -rf ./src/modern-cpp/assets/figures
|
||||
cp ../assets/cover-2nd.png ./src/modern-cpp/assets/cover-2nd.png
|
||||
cp -r ../assets/figures ./src/modern-cpp/assets/figures
|
||||
hexo generate
|
||||
mv public/index.html public/modern-cpp/index.html
|
||||
s:
|
||||
node_modules/serve/bin/serve.js ./public
|
||||
clean:
|
||||
rm ./src/modern-cpp/images/cover-2nd.png
|
||||
rm -rf src/modern-cpp/book
|
||||
rm -rf public db.json
|
||||
rm -rf ./src/modern-cpp/assets/cover-2nd.png
|
||||
rm -rf ./src/modern-cpp/assets/figures
|
||||
rm -rf public db.json src/modern-cpp/book
|
||||
|
||||
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 264 B |
|
Before Width: | Height: | Size: 603 B After Width: | Height: | Size: 603 B |
|
Before Width: | Height: | Size: 724 B After Width: | Height: | Size: 724 B |
|
Before Width: | Height: | Size: 529 B After Width: | Height: | Size: 529 B |
|
Before Width: | Height: | Size: 293 B After Width: | Height: | Size: 293 B |
|
Before Width: | Height: | Size: 894 B After Width: | Height: | Size: 894 B |
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 722 B After Width: | Height: | Size: 722 B |
@@ -9,7 +9,7 @@
|
||||
<div id="hero">
|
||||
<div class="inner">
|
||||
<div class="left">
|
||||
<img class="hero-logo" src="<%- url_for("/modern-cpp/images/cover-2nd.png") %>">
|
||||
<img class="hero-logo" src="<%- url_for("/modern-cpp/assets/cover-2nd.png") %>">
|
||||
</div><div class="right">
|
||||
<h4>欧长坤 著</h4>
|
||||
<h1>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="<%- theme.site_description %>">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/modern-cpp/images/cover-2nd.png">
|
||||
<link rel="shortcut icon" type="image/x-icon" href="/modern-cpp/assets/cover-2nd.png">
|
||||
<meta name="msapplication-TileColor" content="#7e2d36">
|
||||
<meta name="theme-color" content="#7e2d36">
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<div id="header">
|
||||
<a id="logo" href="<%- url_for("/modern-cpp/") %>">
|
||||
<img src="<%- url_for("/modern-cpp/images/cover-2nd.png") %>">
|
||||
<img src="<%- url_for("/modern-cpp/assets/cover-2nd.png") %>">
|
||||
<span>高速上手 C++ 11/14/17</span><sup class="beta">beta</sup>
|
||||
</a>
|
||||
<ul id="nav">
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<li class="nav-dropdown-container language">
|
||||
<a class="nav-link">
|
||||
<span style="content: url(/modern-cpp/images/lang/cn.svg); width: 15px; height: 15px; margin-right: 5px; vertical-align: middle; margin-bottom: 2px;"></span>
|
||||
<span style="content: url(/modern-cpp/assets/lang/cn.svg); width: 15px; height: 15px; margin-right: 5px; vertical-align: middle; margin-bottom: 2px;"></span>
|
||||
中文
|
||||
</a>
|
||||
<!-- TODO -->
|
||||
@@ -34,7 +34,7 @@
|
||||
<ul class="nav-dropdown">
|
||||
<li>
|
||||
<a class="nav-link" target="_blank">
|
||||
<span style="content: url(/modern-cpp/images/lang/en.svg); width: 15px; height: 15px; margin-right: 5px; vertical-align: middle; margin-bottom: 2px;"></span>
|
||||
<span style="content: url(/modern-cpp/assets/lang/en.svg); width: 15px; height: 15px; margin-right: 5px; vertical-align: middle; margin-bottom: 2px;"></span>
|
||||
English (soon)
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -131,13 +131,13 @@ body.docs
|
||||
height: 24px
|
||||
top: 14px
|
||||
left: 12px
|
||||
background: url(../images/menu.png) center center no-repeat
|
||||
background: url(../assets/menu.png) center center no-repeat
|
||||
background-size: 24px
|
||||
.logo
|
||||
position: absolute
|
||||
width: 25px
|
||||
height: 30px
|
||||
background: url(../images/cover-2nd.png) center center no-repeat
|
||||
background: url(../assets/cover-2nd.png) center center no-repeat
|
||||
background-size: auto 100%
|
||||
top: 12px
|
||||
right: 12px
|
||||
|
||||