Hello,
I need an opinion on the way I solve the following problem:
CLASS_NAME contains an object CLASS2 named G2. That contains some large arrays, and some functions, that affects the value of the arrays contained.
I need to create an overload operator() for the class CLASS_NAME with the following structure:
doubleoperator() (const column_vector& x) const
Since there is the final const, this function is not able to modify any element of the CLASS_NAME. And thus I cannot call any function in CLASS2 that is not declared as const.
To solve this problem I simply made a copy of the CLASS 2 object, and then I operate on this new object..
If some_func() isn't const it shouldn't be used in const fucntion. Not "can not", but "should not". If it affects it's operand, you should either create new, const version alongside it, or use a copy of this object to manipulate it.