0
Initialization inside constructor body v/s initializer list?
What is the difference between initializing class data members inside construtor body v/s initializing with constructor initializer list?
4 ответов
+ 1
One of MANY reasons is that when you have a const member. You cannot initialize it inside the constructor, but initializer list.
https://code.sololearn.com/cG3PzTSDo6k1/?ref=app
Other reasons: https://www.geeksforgeeks.org/when-do-we-use-initializer-list-in-c/
0
According to the lesson, constructor initializer allows value initialization for const data members.
https://www.sololearn.com/learn/CPlusPlus/1896/
0
CarrieForle what if my class is have object of another class as it member. Then which would be more preferable to intialize it?
0
Amit chavare You should initialize your members in the initializer list as you can, no matter what type they are.