LearnCpp.com 是一个免费网站,致力于教您如何使用 C++ 进行编程。无论您以前是否有任何编程经验,本站点上的教程都将引导您完成编写、编译和调试 C++ 程序的所有步骤,所有步骤均带有大量示例。
成为专家不会在一夜之间发生,但只要有一点耐心,您就会到达那里。LearnCpp.com 将为您指明方向。
第0章
简介/入门
0.1
这些教程的介绍
0.2
编程语言简介
0.3
C/C++简介
0.4
C++开发简介
0.5
编译器、链接器和库简介
0.6
安装集成开发环境 (IDE)
0.7
编译你的第一个程序
0.8
几个常见的C++问题
0.9
配置编译器:构建配置
0.10
配置编译器:编译器扩展
0.11
配置编译器:警告和错误级别
0.12
配置编译器:选择语言标准
第1章
C++ 基础知识
1.1
语句和程序结构
1.2
评论
1.3
对象和变量简介
1.4
变量赋值和初始化
1.5
iostream 简介:cout、cin 和 endl
1.6
未初始化的变量和未定义的行为
1.7
关键字和命名标识符
1.8
空格和基本格式
1.9
字面量和运算符简介
1.10
表达式介绍
1.11
开发你的第一个程序
1.x
第一章小结与小测验
第2章
C++ 基础:函数和文件
2.1
功能介绍
2.2
函数返回值(value-returning functions)
2.3
Void functions(无值返回函数)
2.4
函数参数和参数介绍
2.5
局部作用域介绍
2.6
为什么函数有用,以及如何有效地使用它们
2.7
转发声明和定义
2.8
具有多个代码文件的程序
2.9
命名冲突和命名空间简介
2.10
预处理器简介
2.11
头文件
2.12
头部护板
2.13
如何设计你的第一个程序
2.x
第二章小结与小测验
第3章
调试 C++ 程序
3.1
语法和语义错误
3.2
调试过程
3.3
调试策略
3.4
基本调试策略
3.5
更多调试策略
3.6
使用集成调试器:步进
3.7
使用集成调试器:运行和断点
3.8
使用集成调试器:观察变量
3.9
使用集成调试器:调用堆栈
3.10
在问题成为问题之前发现问题
3.x
第三章小结与小测验
第 4 章
基本数据类型
4.1
基本数据类型介绍
4.2
空白
4.3
对象大小和 sizeof 运算符
4.4
有符号整数
4.5
无符号整数,以及为什么要避免它们
4.6
固定宽度整数和 size_t
4.7
科学计数法简介
4.8
浮点数字
4.9
布尔值
4.10
if语句简介
4.11
字符
4.12
类型转换和static_cast简介
4.13
Const 变量和符号常量
4.14
编译时常量、常量表达式和 constexpr
4.15
文字
4.16
数字系统(十进制、二进制、十六进制和八进制)
4.17
std::string 简介
4.18
std::string_view 简介
4.x
第四章小结与测验
第 5 章
运营商
5.1
运算符优先级和结合性
5.2
算术运算符
5.3
模数和指数
5.4
递增/递减运算符和副作用
5.5
逗号和条件运算符
5.6
关系运算符和浮点数比较
5.7
逻辑运算符
5.x
第五章小结与测验
O章
位操作(可选章节)
O.1
通过 std::bitset 进行位标志和位操作
O.2
按位运算符
O.3
使用按位运算符和位掩码进行位操作
O.4
二进制和十进制之间的转换
第6章
范围、持续时间和联系
6.1
复合语句(块)
6.2
用户定义的命名空间和范围解析运算符
6.3
局部变量
6.4
全局变量介绍
6.5
变量阴影(名称隐藏)
6.6
内部联动
6.7
外部链接和变量前向声明
6.8
为什么(非常量)全局变量是邪恶的
6.9
跨多个文件共享全局常量(使用内联变量)
6.10
静态局部变量
6.11
范围、持续时间和联系摘要
6.12
使用声明和使用指令
6.13
内联函数
6.14
Constexpr 和 consteval 函数
6.15
未命名和内联命名空间
6.x
第6章小结与测验
第7章
控制流和错误处理
7.1
控制流程介绍
7.2
If 语句和块
7.3
常见的if语句问题
7.4
开关语句基础
7.5
切换失败和范围
7.6
转到语句
7.7
循环和 while 语句简介
7.8
执行 while 语句
7.9
对于语句
7.10
中断并继续
7.11
暂停(提前退出程序)
7.12
代码测试简介
7.13
代码覆盖率
7.14
C++ 中的常见语义错误
7.15
检测和处理错误
7.16
std::cin 和处理无效输入
7.17
断言和 static_assert
7.18
随机数生成简介
7.19
使用 Mersenne Twister 生成随机数
7.x
第7章小结与测验
第8章
类型转换和函数重载
8.1
Implicit type conversion (coercion)
8.2
Floating-point and integral promotion
8.3
Numeric conversions
8.4
Arithmetic conversions
8.5
Explicit type conversion (casting) and static_cast
8.6
Typedefs and type aliases
8.7
Type deduction for objects using the auto keyword
8.8
Type deduction for functions
8.9
Introduction to function overloading
8.10
Function overload differentiation
8.11
Function overload resolution and ambiguous matches
8.12
Default arguments
8.13
Function templates
8.14
Function template instantiation
8.15
Function templates with multiple template types
8.x
Chapter 8 summary and quiz
Chapter 9
Compound Types: References and Pointers
9.1
Introduction to compound data types
9.2
Value categories (lvalues and rvalues)
9.3
Lvalue references
9.4
Lvalue references to const
9.5
Pass by lvalue reference
9.6
Introduction to pointers
9.7
Null pointers
9.8
Pointers and const
9.9
Pass by address
9.10
Pass by address (part 2)
9.11
Return by reference and return by address
9.12
Type deduction with pointers, references, and const
9.x
Chapter 9 summary and quiz
Chapter 10
Compound Types: Enums and Structs
10.1
Introduction to program-defined (user-defined) types
10.2
Unscoped enumerations
10.3
Unscoped enumeration input and output
10.4
Scoped enumerations (enum classes)
10.5
Introduction to structs, members, and member selection
10.6
Struct aggregate initialization
10.7
Default member initialization
10.8
Struct passing and miscellany
10.9
Member selection with pointers and references
10.10
Class templates
10.11
Class template argument deduction (CTAD) and deduction guides
10.x
Chapter 10 summary and quiz
10.y
Using a language reference
Chapter 11
Arrays, Strings, and Dynamic Allocation
11.1
Arrays (Part I)
11.2
Arrays (Part II)
11.3
Arrays and loops
11.4
Sorting an array using selection sort
11.5
Multidimensional Arrays
11.6
C-style strings
11.7
std::string_view (part 2)
11.8
Pointers and arrays
11.9
Pointer arithmetic and array indexing
11.10
C-style string symbolic constants
11.11
Dynamic memory allocation with new and delete
11.12
Dynamically allocating arrays
11.13
For-each loops
11.14
Void pointers
11.15
Pointers to pointers and dynamic multidimensional arrays
11.16
An introduction to std::array
11.17
An introduction to std::vector
11.18
Introduction to iterators
11.19
Introduction to standard library algorithms
11.x
Chapter 11 comprehensive quiz
Chapter 12
Functions
12.1
Function Pointers
12.2
The stack and the heap
12.3
std::vector capacity and stack behavior
12.4
Recursion
12.5
Command line arguments
12.6
Ellipsis (and why to avoid them)
12.7
Introduction to lambdas (anonymous functions)
12.8
Lambda captures
12.x
Chapter 12 comprehensive quiz
Chapter 13
Basic Object-oriented Programming
13.1
Welcome to object-oriented programming
13.2
Classes and class members
13.3
Public vs private access specifiers
13.4
Access functions and encapsulation
13.5
Constructors
13.6
Constructor member initializer lists
13.7
Non-static member initialization
13.8
Overlapping and delegating constructors
13.9
Destructors
13.10
The hidden “this” pointer
13.11
Class code and header files
13.12
Const class objects and member functions
13.13
Static member variables
13.14
Static member functions
13.15
Friend functions and classes
13.16
Anonymous objects
13.17
Nested types in classes
13.18
Timing your code
13.x
Chapter 13 comprehensive quiz
Chapter 14
Operator overloading
14.1
Introduction to operator overloading
14.2
Overloading the arithmetic operators using friend functions
14.3
Overloading operators using normal functions
14.4
Overloading the I/O operators
14.5
Overloading operators using member functions
14.6
Overloading unary operators +, -, and !
14.7
Overloading the comparison operators
14.8
Overloading the increment and decrement operators
14.9
Overloading the subscript operator
14.10
Overloading the parenthesis operator
14.11
Overloading typecasts
14.12
The copy constructor
14.13
Copy initialization
14.14
Converting constructors, explicit, and delete
14.15
Overloading the assignment operator
14.16
Shallow vs. deep copying
14.17
Overloading operators and function templates
14.x
Chapter 14 comprehensive quiz
Chapter 15
Reserved for Future Reorganization
Chapter 16
An Introduction to Object Relationships
16.1
Object relationships
16.2
Composition
16.3
Aggregation
16.4
Association
16.5
Dependencies
16.6
Container classes
16.7
std::initializer_list
16.x
Chapter 16 comprehensive quiz
Chapter 17
Inheritance
17.1
Introduction to inheritance
17.2
Basic inheritance in C++
17.3
Order of construction of derived classes
17.4
Constructors and initialization of derived classes
17.5
Inheritance and access specifiers
17.6
Adding new functionality to a derived class
17.7
Calling inherited functions and overriding behavior
17.8
Hiding inherited functionality
17.9
Multiple inheritance
17.x
Chapter 17 comprehensive quiz
Chapter 18
Virtual Functions
18.1
Pointers and references to the base class of derived objects
18.2
Virtual functions and polymorphism
18.3
The override and final specifiers, and covariant return types
18.4
Virtual destructors, virtual assignment, and overriding virtualization
18.5
Early binding and late binding
18.6
The virtual table
18.7
Pure virtual functions, abstract base classes, and interface classes
18.8
Virtual base classes
18.9
Object slicing
18.10
Dynamic casting
18.11
Printing inherited classes using operator<<
18.x
Chapter 18 comprehensive quiz
Chapter 19
Templates and Classes
19.1
Template classes
19.2
Template non-type parameters
19.3
Function template specialization
19.4
Class template specialization
19.5
Partial template specialization
19.6
Partial template specialization for pointers
19.x
Chapter 19 comprehensive quiz
Chapter 20
Exceptions
20.1
The need for exceptions
20.2
Basic exception handling
20.3
Exceptions, functions, and stack unwinding
20.4
Uncaught exceptions and catch-all handlers
20.5
Exceptions, classes, and inheritance
20.6
Rethrowing exceptions
20.7
Function try blocks
20.8
Exception dangers and downsides
20.9
Exception specifications and noexcept
20.x
Chapter 20 comprehensive quiz
Chapter M
Move Semantics and Smart Pointers
M.1
Introduction to smart pointers and move semantics
M.2
R-value references
M.3
Move constructors and move assignment
M.4
std::move
M.5
std::move_if_noexcept
M.6
std::unique_ptr
M.7
std::shared_ptr
M.8
Circular dependency issues with std::shared_ptr, and std::weak_ptr
M.x
Chapter M comprehensive review
Chapter 21
The Standard Template Library
21.1
The Standard Library
21.2
STL containers overview
21.3
STL iterators overview
21.4
STL algorithms overview
Chapter 22
std::string
22.1
std::string and std::wstring
22.2
std::string construction and destruction
22.3
std::string length and capacity
22.4
std::string character access and conversion to C-style arrays
22.5
std::string assignment and swapping
22.6
std::string appending
22.7
std::string inserting
Chapter 23
Input and Output (I/O)
23.1
Input and output (I/O) streams
23.2
Input with istream
23.3
Output with ostream and ios
23.4
Stream classes for strings
23.5
Stream states and input validation
23.6
Basic file I/O
23.7
随机文件 I/O
附录 A
杂项科目
A.1
静态库和动态库
A2
在 Visual Studio 中使用库
A.3
将库与 Code::Blocks 一起使用
A.4
C++常见问题解答
附录 B
C++ 更新
B.1
C++11简介
B.2
C++14简介
B.3
C++17简介
B.4
C++20简介
附录 C
结束
C.1
结束?
联系客服