This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: multiple inheritance abiguity
- From: John Love-Jensen <eljay at adobe dot com>
- To: Rich Johnson <rjohnson at dogstar-interactive dot com>, Dima Sorkin <dima dot sorkin at gmail dot com>, Gabriel Dos Reis <gdr at cs dot tamu dot edu>
- Cc: MSX to GCC <gcc-help at gcc dot gnu dot org>
- Date: Thu, 19 Jan 2006 08:49:39 -0600
- Subject: Re: multiple inheritance abiguity
Hi Rich,
The reason why the duplicate names cause ambiguity is based on the principle
of least surprise. [I'm not sure what the actual name of the principle is
called, this is just my terminology for it.]
Instead of silently selecting one of the two methods (even given, in the
scenario you mentioned, an exact signature match) the compiler bails with an
error.
Silently selecting one of the two methods could cause unexpected behavior.
The solution is to explicitly provide one-or-both methods in the derived
class which forwards to the respective parents' method.
HTH,
--Eljay