I donβt have a compiler right now, but I think that one inheritance may hide another: the compiler will use Koenig Lookup to find the correct character, and if I remember correctly, as soon as the compiler finds a suitable character (i.e. a method called " submit "), it will stop searching for others in the parent and / or external areas.
In this case, I thought that both inheritance classes would look for a character, but without your exact compiler (Visual C ++ 2003? 2008? 2010?), I can't guess much more.
After some thoughts, another possibility is that the compiler found both characters, but cannot decide which call (at this point in resolving the character, the compiler only cares about the name of the character, not its exact prototype). I believe that this last explanation will be correct.
Try adding with operators to derived classes:
class A : public queue<messageA>, public queue<messageB> { using queue<messageA>::submit ; using queue<messageB>::submit ; } ;
to bring both dispatch methods directly to class A scope.
Also note that your sending methods accept messages as non-constant links, while in the constructor your message parameters are temporary (and therefore constant values ββof r).
Repeatedly name main as:
int main() { A aa; messageA mA ; messageA mB ; aa.submit(mA); aa.submit(mB); }
may help compile (this may explain the compiler error on line 22).
Or you could change the prototype of your submit methods to accept const links instead of non-constant links.
Note: still without a compiler, so try to debug your code ...: -P ...
paercebal
source share