Limitations of initialization list

From: Marcin Kalicinski (kalita_at_poczta.onet.pl)
Date: 08/31/04


Date: Tue, 31 Aug 2004 15:45:06 +0200

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