Skip to content

docs(cpp11/02): add final and override chapter (zh + en)#45

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/cpp11-02-final-and-override-doc
Apr 25, 2026
Merged

docs(cpp11/02): add final and override chapter (zh + en)#45
Sunrisepeak merged 1 commit into
mainfrom
feat/cpp11-02-final-and-override-doc

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

补齐 cpp11 第 2 章 `final 和 override` 的中英文文档(之前两边都缺)。

  • `book/src/cpp11/02-final-and-override.md` (zh)
  • `book/en/src/cpp11/02-final-and-override.md` (en)
  • 两个 `SUMMARY.md` 在 01 和 09 之间插入新条目

风格 / 结构对齐已有章节(参照 ch00 auto-and-decltype 和 ch11 inherited-constructors):

  • 顶部语言切换 + cppreference / markdown / 视频解读 / 练习代码 资源表
  • `为什么引入? / 两者的语义区别?` 开头 Q&A
  • `## 一、基础用法和场景` / `## 二、注意事项` / `## 三、练习代码` / `## 四、其他` 编号小节
  • `## 三、练习代码` 列出对应的 3 个练习题(02-final-and-override-{0,1,2})+ `d2x checker final-and-override` 自动检测命令
  • footer 4 链固定(交流讨论 / 仓库 / 视频列表 / xlings)

内容覆盖:override 显式重写 + 编译期校验、final 修饰虚函数和类的两种用法、final + 纯虚的 NVI 模板方法(直接对应 02-2 的 AudioPlayer/WAV/MP3/OGG 练习)、上下文相关标识符(解释为什么 dslings 里能用 `B override;` / `B final;` 当变量名)、override 必须配合 virtual、final 类慎用、final 不能用在非虚函数、override + final 可叠加。

视频单元格留空 (`视频解读` / `Video Explanation`),沿用 12-nullptr / 13-long-long 的"暂未录制"约定。

Test plan

  • `mdbook build book` 在 zh 端不报 SUMMARY 链接 broken(本地 mdbook 版本不匹配跑不起来,请 reviewer / CI 跑一下)
  • `mdbook build book/en` 同上
  • 在线渲染后两侧顶部语言切换链接互通(zh -> en,en -> zh)
  • SUMMARY 中新条目顺序正确(01 → 02 → 09)

Adds the missing tutorial doc for chapter 02 in both languages, mirroring
the structure of existing chapters (00, 11): resource table, Why /
Difference Q&A, "I. Basic Usage", "II. Important Notes", "III. Practice
Code", "IV. Additional Resources" footer. Covers override for explicit
overriding, final on virtual functions and on classes, the final + pure
virtual NVI pattern (matching the AudioPlayer/WAV/MP3/OGG exercise), and
context-sensitive identifier semantics.

SUMMARY.md updated in both zh and en to insert the new entry between 01
and 09.
@Sunrisepeak Sunrisepeak merged commit cdfc186 into main Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant