If I have a class which will initialise a member value in such a way that it is not trivial enough to be performed directly within the initialiser list, what is the correct way of initialising that member variable?
class Rectangle
{
private:
const int area;
int init_area(const int width, const int height) const { return (width*height); }
public:
Rectangle(const int width, const int height) : area(init_area()) {}
}
Obviously in this case initialising the Rectangle's area is trivial enough to be done inline, but let's pretend that that isn't the case and init_area() does something more complex.
Is it standard practice to initialise members this way? If so I can't seem to find it used very often in literature (the first hundred pages of cppcoreguidelines for example).
If this is not good practice please could you detail the alternative(s) and why the above method if flawed?