# No default constructor in base class

## Recommended Posts

Kest    547
I want a hierarchy of objects to be created with constructors that accept specific parameters. I matched the base class constructor overrides to the derived types, hoping they would get automatically called before the derived versions, but my ill-advised plans were smoked by reality. Only the base class default constructor was called. And when I tried removing the default (so that only the matching overrides remain), I can't compile it. Hopefully this will make it clear..
Car::Car(const MyData &data)
{
.. I want Base::Base( data ) to be auto-called right here ..

// otherwise, I have to do something like this..?
Base::OnConstruct( data );

... init other data ...
}
Is there some trick to getting this to work? Thanks for any information

##### Share on other sites
K_I_L_E_R    142
Does this help?

Car::Car(const MyData &data) : Base(data){...}

##### Share on other sites
Kest    547
As well as I can be helped. Thanks very much.