M
Marcin Kalicinski
Hi,
Constructor of derived class needs to do some complex things before it calls
base class constructor. There is an ugly solution:
bool ComplexThingToDo()
{
// ...
return false; // dummy
}
class Derived: public Base
{
bool dummy;
public:
Derived(): dummy(ComplexThingToDo()), Base() { }
};
But I'm afraid that sequence of initializers in initialization list does not
enforce the actual sequence of execution. So this ugly solution will not
work. Is there another way? Perhaps it is an example of bad design, doing
some complex things before calling base class constructor?
Best regards,
Marcin
Constructor of derived class needs to do some complex things before it calls
base class constructor. There is an ugly solution:
bool ComplexThingToDo()
{
// ...
return false; // dummy
}
class Derived: public Base
{
bool dummy;
public:
Derived(): dummy(ComplexThingToDo()), Base() { }
};
But I'm afraid that sequence of initializers in initialization list does not
enforce the actual sequence of execution. So this ugly solution will not
work. Is there another way? Perhaps it is an example of bad design, doing
some complex things before calling base class constructor?
Best regards,
Marcin