"Catalin Pitis" <ca***********@iquestint.com.renameme> wrote in message
news:2u*************@uni-berlin.de...
Unfortunately, the constructors are not inherited. So, if you want to keep
the same constructors for the derived class, you should declare them in
the derived clas with the same interface as in the base class and call the
base class constructors with the specified parameters. Unfortunately, it means
a lot of (unnecessary) code to be written. Fortunately, from the performance
point of view, these calls can be optimized by the compiler.
However, you should think: Are all the base class constructors really
necessary in the derived class?
Thanks for that.
In my particular case there are about 6-7 different constuctors and I've
explicitly reproduced these in my derived class.
In reality, I believe only 1 or 2 of these constructors will be used with my
new class, however it seems safer to assume they all could be used since the
object I'm modifiying is used in a lot of places and is subject to change by
other coders. If I did limit my new constructors to those I believed
necessary and I missed one (or an unmodified one was subsequently used) then
I run the risk of having uninitialised data used?
It seems surprising that c++ doesn't provide a mechanism for a global
initialisation of member variables or at least some compiler warnings when
these are not initialised (I'm using MS Visual Studio)
Thanks again.