The following initializer is in error. Identify and fix the problem
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:36
All Answers
total answers (1)
belongs to book: C++ Primer|Stanley B.Lippman, Josee Lajoie, Barbara E.Moo|5th Edition| Chapter number:7| Question number:36
total answers (1)
The order of member initialization is the same with the order they appear in the class definition. Since
`rem`appears first, it will be initialized first. But the value of`base`is undefined when`rem`is initialized, thus the value of`rem`is undefined. To fix the problem, we can either switch the order of definitions of`rem`and`base`or we can use the constructor parameters`i`and`j`direct initialize`rem(i % j)`.
need an explanation for this answer? contact us directly to get an explanation for this answer