Is there a best practice for deferred initialization of a private member of a class of a Mclass C? For example:
class C {
public:
C();
someSimpleStuff();
startWork(int param);
doProcessing();
private:
M m;
};
class M {
M(int param);
};
Class objects Ccannot be built because they Mdo not have a default initializer.
If you can change the implementation M, you can add a method initto Mand make its constructor take no arguments, which would allow you to build class objects C.
If not, you can wrap the element C Min std::unique_ptrand build it when possible.
, . , , M ?
: C , , C public .