Skip to content

Commit

Permalink
docs: 优化代码、描述和提示
Browse files Browse the repository at this point in the history
Signed-off-by: YdrMaster <[email protected]>
  • Loading branch information
YdrMaster committed Jul 17, 2024
1 parent b6cc63d commit ac3dc00
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
5 changes: 2 additions & 3 deletions exercises/02_function/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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: 补全函数定义,但不要移动代码行
}
2 changes: 1 addition & 1 deletion exercises/03_argument&parameter/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "../exercise.h"

static void func(int);
void func(int);

// TODO: 为下列 ASSERT 填写正确的值
int main(int argc, char **argv) {
Expand Down
9 changes: 6 additions & 3 deletions exercises/04_static/main.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include "../exercise.h"

int func(int param) {
// READ: `static` 关键字 <https://zh.cppreference.com/w/cpp/language/storage_duration>
// 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");
Expand Down
2 changes: 1 addition & 1 deletion exercises/23_std_vector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion exercises/xmake.lua
Original file line number Diff line number Diff line change
@@ -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")

Expand Down

0 comments on commit ac3dc00

Please sign in to comment.