This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Inheritance/overloading problem
- To: <gcc at gcc dot gnu dot org>
- Subject: Inheritance/overloading problem
- From: "Dean Wakerley" <dean at housefloors dot co dot uk>
- Date: Tue, 4 Sep 2001 15:54:46 +0100
- Organization: Rackham Housefloors Ltd.
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