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]

Inheritance/overloading problem


I'm getting this error message when compiling the following code.

test.cc: In function `int main()':
test.cc:31: no matching function for call to `top_c::func (char)'
test.cc:20: candidates are: void top_c::func()

// ----- start of code ---------
#include <iostream>

class base_c
{
public:
  virtual void func()=0;
  virtual void func(char)=0;
};

class middle_c
{
public:
  void func() { cout << "middle_c::func()" << endl; };
  void func(char) { cout << "middle_c::func(char)" << endl; };
};

class top_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 ---------

Is this a language problem or a compiler problem?, and how do I get around
it?

TIA,
Dean




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