Short answer: don't do it.
Explanation:
When object
is constructed, the object is of type object
, not the derived class yet. Let's call the derived class my_object
.
Any virtual function (pure or not) that your in object's constructor will call object's version.
Only in the body of my_object::my_object()
the object type is my_object
, not before.
The solution is to separate construction from initialization.
From my_object::my_object()
call a virtual function Initialize or better, expose it as a public method so the code that created the my_object instance will call it to initialize the object.
Example:
my_object o;
o.Init(params);