Skip to content

Commit

Permalink
更改
Browse files Browse the repository at this point in the history
  • Loading branch information
haiduo committed Aug 15, 2019
1 parent cce2cbf commit 3c2dc26
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions excersize/ch06.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ int generate()
int fact(int val);
int func();

template <typename T>
template <typename T> //参考:https://blog.csdn.net/fightingforcv/article/details/51472586

T abs(T i)
{
return i >= 0 ? i : -i;
Expand Down Expand Up @@ -554,7 +555,7 @@ void print(const int ia[10])

当数组作为实参的时候,会被自动转换为指向首元素的指针。
因此函数形参接受的是一个指针。
如果要让这个代码成功运行,可以将实参改为数组的引用
如果要让这个代码成功运行(不更改也可以运行),可以将形参改为数组的引用

```cpp
void print(const int (&ia)[10])
Expand Down Expand Up @@ -741,7 +742,7 @@ string s[10];
decltype(s)& fun();
```

我觉得尾置返回类型最好。
我觉得尾置返回类型最好,就一行代码

## 练习6.38
修改`arrPtr`函数,使其返回数组的引用。
Expand Down Expand Up @@ -823,7 +824,7 @@ string make_plural(size_t ctr, const string& word, const string& ending = "s")

int main()
{
cout << "singual: " << make_plural(1, "success", "es") << " "
cout << "single: " << make_plural(1, "success", "es") << " "
<< make_plural(1, "failure") << endl;
cout << "plural : " << make_plural(2, "success", "es") << " "
<< make_plural(2, "failure") << endl;
Expand Down

0 comments on commit 3c2dc26

Please sign in to comment.