Skip to content

Commit 02e77f2

Browse files
authored
Merge pull request #53 from chiry163/chiry163-patch-1
Update ch12.md
2 parents 6f5ca58 + 561c228 commit 02e77f2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

excersize/ch12.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ int main()
120120
解:
121121

122122
构造函数不是 `explicit` 的,意味着可以从 `initializer_list` 隐式转换为 `StrBlob`。在 `StrBlob` 对象中,只有一个数据成员 `data`,而 `StrBlob` 对象本身的含义,也是一个**管理字符串的序列**。因此,从 `initializer_list``StrBlob` 的转换,在逻辑上是可行的。而这个设计策略的缺点,可能在某些地方我们确实需要 `initializer_list`,而编译器仍会将之转换为 `StrBlob`
123+
explicit阻止了构造函数的隐式转换,只能将函数直接初始化,不能拷贝初始化。这种设计让程序变得容易使用但是很难dubug。
123124

124125
## 练习12.6
125126

@@ -987,4 +988,4 @@ public:
987988
private:
988989
// ...
989990
};
990-
```
991+
```

0 commit comments

Comments
 (0)