File tree 5 files changed +11
-9
lines changed
5 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,6 @@ int main(int argc, char **argv) {
10
10
return 0 ;
11
11
}
12
12
13
- // TODO: 补全函数定义,但不要移动代码行
14
- // THINK: `static` 修饰函数有什么效果?
15
- static int add (int a, int b) {
13
+ int add (int a, int b) {
14
+ // TODO: 补全函数定义,但不要移动代码行
16
15
}
Original file line number Diff line number Diff line change 2
2
3
3
#include " ../exercise.h"
4
4
5
- static void func (int );
5
+ void func (int );
6
6
7
7
// TODO: 为下列 ASSERT 填写正确的值
8
8
int main (int argc, char **argv) {
Original file line number Diff line number Diff line change 1
1
#include " ../exercise.h"
2
2
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) {
4
6
static int static_ = param;
5
- std::cout << " static_ = " << static_++ << std::endl;
6
- return static_;
7
+ // std::cout << "static_ = " << static_ << std::endl;
8
+ return static_++ ;
7
9
}
8
10
9
11
int main (int argc, char **argv) {
12
+ // TODO: 将下列 `?` 替换为正确的数字
10
13
ASSERT (func (5 ) == ?, " static variable value incorrect" );
11
14
ASSERT (func (4 ) == ?, " static variable value incorrect" );
12
15
ASSERT (func (3 ) == ?, " static variable value incorrect" );
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ int main(int argc, char **argv) {
63
63
auto capacity = vec.capacity ();
64
64
vec.resize (16 );
65
65
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." );
67
67
}
68
68
{
69
69
vec.reserve (256 );
Original file line number Diff line number Diff line change 1
1
add_rules (" mode.debug" , " mode.release" )
2
2
set_encodings (" utf-8" )
3
- set_warnings (" all" , " error " )
3
+ set_warnings (" all" )
4
4
set_kind (" binary" )
5
5
set_languages (" cxx17" )
6
6
You can’t perform that action at this time.
0 commit comments