Inheritance/overloading problem (corrected post: ignore previous)
Gabe Foster
gabe@sgrail.com
Tue Sep 4 08:41:00 GMT 2001
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
More information about the Gcc
mailing list