[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: what is this error?

From: Ulrich Eckhardt
Subject: Re: what is this error?
Date: Tue, 02 Nov 2004 17:42:09 +0100
User-agent: KNode/0.7.7

Gav Wood wrote:
> i'm trying to compile (fairly simple) code that uses inheritance:

Fairly simple? Hmm-humm....

> it looks like this:
> namespace geddei {
>         class Processor: ...
>         {
>                 Processor(const QString &type): ... {}
>         };
> }
> class NProcessor: virtual public geddei::Processor, ...
> {
>         NProcessor(const QString &type, int a): Processor(type), ... {}
> };
> class TMO: public NProcessor
> {
>         TMO(): NProcessor("TMO", 1) {}
> };
> the error i'm getting is:
> testmulti.cpp:388: error: no matching function for call to
> `geddei::Processor::Processor(const <anonymous>**)' 
> processor.h:112: error: candidates are:
> geddei::Processor::Processor(const geddei::Processor&)
> geddei::Processor::Processor(const QString&)
> the error points to the TMO constructor line: if i comment out the class
> TMO, it compiles fine. i dont see why this is, since TMO doesn't
> (directly) refer to Processor.

Yes it does. ;)

The point is, that with virtual(!) inheritance, the most derived class(in
this case that is TMO) is the one that really instantiates the base
subobject that was virtually derived from.

The reason is that two baseclasses could be virtually derived from the same
base, and both could provide different parameters to their base, so that
makes no sense - I think every concrete class along the tree has to call
the virtual base's ctor with proper parameters.

If you want a definitive answer, I suggest asking that question on



reply via email to

[Prev in Thread] Current Thread [Next in Thread]