diff --git a/exercises/02_function/main.cpp b/exercises/02_function/main.cpp index a5681be7..1de1c2a6 100644 --- a/exercises/02_function/main.cpp +++ b/exercises/02_function/main.cpp @@ -10,7 +10,6 @@ int main(int argc, char **argv) { return 0; } -// TODO: 补全函数定义,但不要移动代码行 -// THINK: `static` 修饰函数有什么效果? -static int add(int a, int b) { +int add(int a, int b) { + // TODO: 补全函数定义,但不要移动代码行 } diff --git a/exercises/03_argument¶meter/main.cpp b/exercises/03_argument¶meter/main.cpp index 5c8f8b10..764f12bd 100644 --- a/exercises/03_argument¶meter/main.cpp +++ b/exercises/03_argument¶meter/main.cpp @@ -2,7 +2,7 @@ #include "../exercise.h" -static void func(int); +void func(int); // TODO: 为下列 ASSERT 填写正确的值 int main(int argc, char **argv) { diff --git a/exercises/04_static/main.cpp b/exercises/04_static/main.cpp index d8bcc6ca..f107762f 100644 --- a/exercises/04_static/main.cpp +++ b/exercises/04_static/main.cpp @@ -1,12 +1,15 @@ #include "../exercise.h" -int func(int param) { +// READ: `static` 关键字 +// THINK: 这个函数的两个 `static` 各自的作用是什么? +static int func(int param) { static int static_ = param; - std::cout << "static_ = " << static_++ << std::endl; - return static_; + // std::cout << "static_ = " << static_ << std::endl; + return static_++; } int main(int argc, char **argv) { + // TODO: 将下列 `?` 替换为正确的数字 ASSERT(func(5) == ?, "static variable value incorrect"); ASSERT(func(4) == ?, "static variable value incorrect"); ASSERT(func(3) == ?, "static variable value incorrect"); diff --git a/exercises/23_std_vector/main.cpp b/exercises/23_std_vector/main.cpp index 8358a9d1..c82e7c37 100644 --- a/exercises/23_std_vector/main.cpp +++ b/exercises/23_std_vector/main.cpp @@ -63,7 +63,7 @@ int main(int argc, char **argv) { auto capacity = vec.capacity(); vec.resize(16); ASSERT(vec.size() == ?, "Fill in the correct value."); - ASSERT(vec.capacity() == ?, "Fill in the correct identifier."); + ASSERT(vec.capacity() == ?, "Fill in a correct identifier."); } { vec.reserve(256); diff --git a/exercises/xmake.lua b/exercises/xmake.lua index 82b2f5d9..2f8922c7 100644 --- a/exercises/xmake.lua +++ b/exercises/xmake.lua @@ -1,6 +1,6 @@ add_rules("mode.debug", "mode.release") set_encodings("utf-8") -set_warnings("all", "error") +set_warnings("all") set_kind("binary") set_languages("cxx17")