Why didn’t we use in-class initializers in PersonInfo
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:8| Question number:12
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:8| Question number:12
total answers (1)
Because the synthesised default constructor will be called when an object of class
`PersonInfo`is created, which will default initialized its data members. Meanwhile, both`string`and`vector`have default constructors, and will be used when default initialized. Thus, we don't need in-class initializers to initialze data members in`PersonInfo`.
need an explanation for this answer? contact us directly to get an explanation for this answer