Skip to content

Commit ac3dc00

Browse files
committed
docs: 优化代码、描述和提示
Signed-off-by: YdrMaster <[email protected]>
1 parent b6cc63d commit ac3dc00

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

exercises/02_function/main.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ int main(int argc, char **argv) {
1010
return 0;
1111
}
1212

13-
// TODO: 补全函数定义,但不要移动代码行
14-
// THINK: `static` 修饰函数有什么效果?
15-
static int add(int a, int b) {
13+
int add(int a, int b) {
14+
// TODO: 补全函数定义,但不要移动代码行
1615
}

exercises/03_argument&parameter/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../exercise.h"
44

5-
static void func(int);
5+
void func(int);
66

77
// TODO: 为下列 ASSERT 填写正确的值
88
int main(int argc, char **argv) {

exercises/04_static/main.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
#include "../exercise.h"
22

3-
int func(int param) {
3+
// READ: `static` 关键字 <https://zh.cppreference.com/w/cpp/language/storage_duration>
4+
// THINK: 这个函数的两个 `static` 各自的作用是什么?
5+
static int func(int param) {
46
static int static_ = param;
5-
std::cout << "static_ = " << static_++ << std::endl;
6-
return static_;
7+
// std::cout << "static_ = " << static_ << std::endl;
8+
return static_++;
79
}
810

911
int main(int argc, char **argv) {
12+
// TODO: 将下列 `?` 替换为正确的数字
1013
ASSERT(func(5) == ?, "static variable value incorrect");
1114
ASSERT(func(4) == ?, "static variable value incorrect");
1215
ASSERT(func(3) == ?, "static variable value incorrect");

exercises/23_std_vector/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int main(int argc, char **argv) {
6363
auto capacity = vec.capacity();
6464
vec.resize(16);
6565
ASSERT(vec.size() == ?, "Fill in the correct value.");
66-
ASSERT(vec.capacity() == ?, "Fill in the correct identifier.");
66+
ASSERT(vec.capacity() == ?, "Fill in a correct identifier.");
6767
}
6868
{
6969
vec.reserve(256);

exercises/xmake.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
add_rules("mode.debug", "mode.release")
22
set_encodings("utf-8")
3-
set_warnings("all", "error")
3+
set_warnings("all")
44
set_kind("binary")
55
set_languages("cxx17")
66

0 commit comments

Comments
 (0)