const and references initialisation lists
Why do always non-static const and non-static reference data members need to be initialised in initilisation lists?
Quote:Original post by TEUTON
Why do always non-static const and non-static reference data members need to be initialised in initilisation lists?
Because both are designed to be types that cannot be changed in the code, only in initialization stage (and that's exactly what the initializer list is for!)
Quote:Original post by MindFlayerQuote:Original post by TEUTON
Why do always non-static const and non-static reference data members need to be initialised in initilisation lists?
Because both are designed to be types that cannot be changed in the code, only in initialization stage (and that's exactly what the initializer list is for!)
To expand a bit on this, by the time you actually enter your constructor, all your members have been initialized. Everything that happens within your constructor is an assignment.
CM
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement