1 Star 0 Fork 1

Jasd寒夜 / c++20 tutorial

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

ReadMe

说明:

c++20_pro_src 文件夹 和 ProC++ Final Exercise Solutions 文件夹

  1. 来自C++20高级编程 源码 与 课后练习题。 2. 编译使用gcc(g++) 12.x 版本。 此版本暂不支持c++20 引入的 std::format 库。 所以代码将进行替换使用printf进行格式化或字符串输出。 (可使用第三方fmt库进行替换,考虑这个repo仅做c++语言学习使用,为了code的简介所以暂不考虑引用第三方fmt库)
  2. 使用gcc13 以上版本支持 库
  3. 书中大量使用module,考虑到编译器module编译存在bug不是很清楚。 将对源码中的repo module进行改写为熟悉的 xxx.hxxx.cpp 文件格式。

重点章节

  • chapter2 介绍C-Style的字符串和c++11之后引入的 string 及c++17后引入的string_view。
  • chapter7 c++指针概念
  • chapter8 介绍class
  • chapter9 进一步检查class及相关高级内容 , copy constructorcopy assginment constructormove constructor
  • chapter12 重点概念 泛型编程。创建通用模板
  • chapter13 stream 流的概念
  • chapter15 运算符重载
  • chapter16 StandardLib 介绍,包括C++20 引入的<bit>库,cpm_equal()Container and Algorithm 重点内容
  • chapter17 iterator 介绍, c++20 新增的 range 和view 的使用
  • chapter18 stl容器详细介绍,原理及相关使用方法。 重点章节

编译存在问题

  1. g++ 不识别书中定义的.cppm 模块文件, 需要将模块文件后缀更改为.cxx;

  2. g++ 在编译时需要指定 编译的c++版本-std=c++20,和使用模块编译 -fmodules-ts

  3. . 标准库无法直接导入需要手动将其编译生module 在进行编译

(c01_code/01_HelloWorld/helloworld.cpp) 中编译语句

# 将iostream string 编译成单元进行输出
g++ -std=c++20 -fmodules-ts -xc++-system-header iostream
g++ -std=c++20 -fmodules-ts -xc++-system-header string

# 在编译生成对应文件。 
g++ -std=gnu++20 -fmodules-ts .\helloworld.cpp  -o hello.exe 

  1. 编译多线程模块时,g++ 需要使用posixs 版本, win32版本暂不支持c++11之后的thread
MIT License Copyright (c) 2024 Jasd寒夜 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

c++20 高级编程 课本源代码。 非module版本 展开 收起
C++ 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C++
1
https://gitee.com/jasd1996/c20-tutorialc.git
git@gitee.com:jasd1996/c20-tutorialc.git
jasd1996
c20-tutorialc
c++20 tutorial
master

搜索帮助