2 ms·
>2-step initialisation is the only way around errors during construction whilst forbidding exceptions. Static methods returing optional<T> or some more refined
by gpderetta 7y ago
>2-step initialisation is the only way around errors during construction whilst forbidding exceptions.
Static methods returing optional<T> or some more refined either type work fine and don't suffer the from the dreaded zombie state issue.
Having spent the last week fixing bugs after a refactoring of a class hierarchy that would somtimes leave base classes half initialized, I say please, for the sake of maintainability, dont use init methods!