ReadingLab / Discussion-for-Cpp

C++ 中文讨论区
MIT License
88 stars 63 forks source link

Exercise 8.12的答案 #44

Open HypnoS-s opened 9 years ago

HypnoS-s commented 9 years ago

C++ primer 5th Page 322.Exercise 8.12

Why didn’t we use in-class initializers in PersonInfo?

答案是

Cause we need a aggregate class here. so it should have no in-class initializers.

这里为什么需要aggregate class? 我觉得原因应该是没有必要这么做吧。

Mooophy commented 9 years ago

。。书上的PersonInfo 就已经是aggregate class了。

huangmingchuan commented 8 years ago

@Mooophy 我也看到这里了,为什么没有在 PersonInfo 类中使用类内初始化?

答案说我们需要聚合类,为什么需要聚合类呢?

oiu850714 commented 4 years ago

這個情境下對 PersonInfo 做任何預設初始化應該都不合理? 給它一個預設號碼或名稱應該沒有意義