This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Inheritance/overloading problem (corrected post: ignore previous)


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]