Skip to content

Commit

Permalink
book: use curly brackets to initailize aggregate objects (changkun#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
TinyWang authored and changkun committed Aug 10, 2020
1 parent 9dbdd53 commit 4de9eb4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions book/en-us/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,10 @@ auto arr = new auto(10); // arr as int *
> In addition, `auto` cannot be used to derive array types:
>
> ```cpp
> auto auto_arr2[10] = arr; // illegal, can't infer array type
> auto auto_arr2[10] = {arr}; // illegal, can't infer array type
>
> 2.6.auto.cpp:30:19: error: 'auto_arr2' declared as array of 'auto'
> auto auto_arr2[10] = arr;
> auto auto_arr2[10] = {arr};
> ```
### decltype
Expand Down
4 changes: 2 additions & 2 deletions book/zh-cn/02-usability.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ auto arr = new auto(10); // arr 被推导为 int *
> 此外,`auto` 还不能用于推导数组类型:
>
> ```cpp
> auto auto_arr2[10] = arr; // 错误, 无法推导数组元素类型
> auto auto_arr2[10] = {arr}; // 错误, 无法推导数组元素类型
>
> 2.6.auto.cpp:30:19: error: 'auto_arr2' declared as array of 'auto'
> auto auto_arr2[10] = arr;
> auto auto_arr2[10] = {arr};
> ```
### decltype
Expand Down
2 changes: 1 addition & 1 deletion code/2/2.06.auto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int main() {
auto i = 5; // type int
auto j = 6; // type int
auto arr = new auto(10); // type int*
// auto auto_arr2[10] = arr;
// auto auto_arr2[10] = {arr};
// std::cout << add(i, j) << std::endl;
return 0;
}

0 comments on commit 4de9eb4

Please sign in to comment.