keith@bytebrothers.co.uk wrote:
> Hi, I've been through the FAQ-lite and can't see this mentioned, so
> here goes...
>
> I've got an abstract base class called Base which has no copy
> constructor at all. In the derived class I have something like this:
>
> // derived.h-----------------------------------------------------
> class DerivedPrivate; // Not defined here
> class Derived : public Base
> {
> private:
> class DerivedPrivate* const p_;
>
> public:
> Derived();
> Derived(const Derived& s);
> // remainder snipped
> }
> // end--------------------------------------------------------------
>
> // derived.cc----------------------------------------------------
> // definition of DerivedPrivate skipped
> Derived:
erived() : p_(new DerivedPrivate()) {}
>
> Derived:
erived(const Derived& s) : p_(new DerivedPrivate())
> { *p_ = *(s.p_); }
> // remainder skipped
> // end--------------------------------------------------------------
>
> Now this all compiles and works just fine, but when I turn on "-Wall -
> W" in gcc, it tells me that:
>
> derived.cc:134: warning: base class 'class Base' should be explicitly
> initialized in the copy constructor
>
> I'm afraid I'm being rather dense today, as I don't understand what
> it's complaining about. Can someone explain for me please?
>
It complains that you should write your Derived ctor in this way:
Derived:

erived()
: Base()
, p_(new DerivedPrivate())
{}