Package: g++ Version: 2:2.95.4-14 Severity: normal If you try to compile the program given below you will get the following:
$ g++ test.cc test.cc: In function `int main()': test.cc:24: no matching function for call to `B::p1 (int)' test.cc:16: candidates are: void B::p1() So, the function B::p1(int) is not found even though it should be inherited from class A. The problem seems to be that p1 is overloaded and p1() is redefined and p1(int) is not. For p2 no (overloaded) function is redefined and it works w/o problem (just comment the line 'b->p1(1);' in main): both functions are inherited from class A. Everything also works w/o problem if b is declared as A*, instead of B*, i.e. a pointer to the base class. I am not sure this is a bug, but I thought that the inheritance should work also in this case (i.e. with overloaded functions). When using g++-3.0 I get the same result. Many Greetings, Heiko test.cc looks like this: ------------------------- $ cat test.cc #include <iostream> using namespace std; class A { public: virtual void p1() {cout<<"ap1 "<<endl;} virtual void p1(int i) {cout<<"ap1 "<<i<<endl;} virtual void p2() {cout<<"ap2 "<<endl;} virtual void p2(int i) {cout<<"ap2 "<<i<<endl;} }; class B : public A { public: void p1() {cout<<"bp1"<<endl;} }; int main () { B* b = new B; // does not work //A* b = new B; // works b->p1(); b->p2(); b->p1(1); // comment this line and it also works b->p2(1); } -- System Information Debian Release: 3.0 Architecture: i386 Kernel: Linux xpc19 2.4.19 #7 Mon Aug 19 16:01:05 CEST 2002 i686 Locale: LANG=C, LC_CTYPE=C Versions of packages g++ depends on: ii cpp 2:2.95.4-14 The GNU C preprocessor. ii g++-2.95 1:2.95.4-11woody1 The GNU C++ compiler. ii gcc-2.95 1:2.95.4-11woody1 The GNU C compiler.