When the body of the constructor is executed, all the members of the object data are already created. Therefore, in this constructor
object::object() { this->mass = 1; }
in a sentence
this->mass = 1;
an assignment operator is used that cannot be used with constant objects.
If you need to determine the value of a constant data member based on some calculations, then use some, for example, a static function - a member of the class as the initializer.
object::object( some_argument ): mass( some_function( some_argument ) ) { }
Function arguments do not have to be constructor arguments. You can use static data members of a class, not statically data members that have already been initialized in the initialization list (lags in the class declaration must precede, or objects that are within the scope of the constructor definition.
The following is an example.
#include <iostream> class Object { public: Object( double x ) : x ( 2 * x ), mass( init( this->x ) ) { } double get_mass() const { return mass; } private: double x; const double mass; static double init( double x ) { return x < 0 ? -x / 2 : x; } }; int main() { Object obj( 10 ); std::cout << obj.get_mass() << std::endl; return 0; }