Hi guys,
suppose I have a set of instance variables declared as const double, I would like to initialise them in the constructor.
Besides of initalising in the ctor list (e.g. MyClass() : my_const_var(0), my_const_var2(init_var2()), etc.. { }), is there any way to set their value inside the constructor body ?
No, inside the constructor body you may not iniialize them because there is used an assignment instead initialization.
However you can declare them as constexpr static variables and assign them values in the class definition. For example