This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Inheritance/overloading problem (corrected post: ignore previous)
- To: "Dean Wakerley" <dean at housefloors dot co dot uk>, <gcc at gcc dot gnu dot org>
- Subject: Re: Inheritance/overloading problem (corrected post: ignore previous)
- From: Gabe Foster <gabe at sgrail dot com>
- Date: Tue, 4 Sep 2001 10:36:25 -0600
- Organization: Silicon Grail
- References: <000601c13554$e5cb1060$0b0b11ac@rhf.net>
On Tuesday 04 September 2001 09:18 am, Dean Wakerley wrote:
> // ----- start of code ---------
> #include <iostream>
>
> class base_c
> {
> public:
> virtual void func()=0;
> virtual void func(char)=0;
> };
>
> class middle_c: public base_c
> {
> public:
> void func() { cout << "middle_c::func()" << endl; };
> void func(char) { cout << "middle_c::func(char)" << endl; };
> };
>
> class top_c: public middle_c
> {
> public:
> void func() { cout << "top_c::func()" << endl; };
> /* void func(char);
> * use function inherited from middle_c
> */
> };
>
> int
> main(/*...*/)
> {
> top_c t;
> t.func(); // works
> t.func('x'); // problem: no matching function???
> return 0;
> }
>
> // ----- end of code ---------
The declaration of top_c is missing the following statement:
using middle_c::func;
so it would look like
class top_c: public middle_c
{
public:
using middle_c::func;
void func() { cout << "top_c::func()" << endl; };
/* void func(char);
* use function inherited from middle_c
*/
};
I don't have access to GCC on the machine I'm on, so I don't know if this is
implemented yet, but it is in the standard.
--> Gabe
--
* J. Gabriel Foster "We have advanced to new and surprising
* Silicon Grail levels of bafflement" - Lois McMaster Bujold
* gabe@sgrail.com