I just got into a new company and much of the code base uses initialization methods instead of constructors.
struct MyFancyClass : theUberClass
{
MyFancyClass();
~MyFancyClass();
resultType initMyFancyClass(fancyArgument arg1, classyArgument arg2,
redundantArgument arg3=TODO);
// several fancy methods...
};
They told me that this had something to do with timing. That some things have to be done after construction that would fail in the constructor. But most constructors are empty and I don't really see any reason for not using constructors.
So I turn to you, oh wizards of the C++: why would you use an init-method instead of a constructor?
See Question&Answers more detail:os