This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
bug report
- To: gcc-bugs at gcc dot gnu dot org
- Subject: bug report
- From: Michael Orlov <orlovm at CS dot BGU dot AC dot IL>
- Date: Sun, 14 May 2000 20:26:58 +0300 (IDT)
- CC: orlovm at cs dot bgu dot ac dot il, asis at cs dot bgu dot ac dot il
Version:
--------
orlovm-silver:~/progs/c> g++ -v
Reading specs from /usr/local/gcc-2.95.2/lib/gcc-lib/sparc-sun-solaris2.6/2.95.2/specs
gcc version 2.95.2 19991024 (release)
System Type (also checked on linux)
-----------------------------------
orlovm-silver:~/progs/c> uname -a
SunOS silver 5.6 Generic_105181-19 sun4u sparc SUNW,Ultra-4
Command line
------------
orlovm-silver:~/progs/c> g++ -o a a.cc
a.cc: In function `int main()':
a.cc:17: no matching function for call to `B::boo ()'
a.cc:10: candidates are: int B::boo(int)
a.cc:18: no matching function for call to `B::boo ()'
a.cc:10: candidates are: int B::boo(int)
Source
------
#include <iostream.h>
class A {
public:
int boo() { return 1; }
};
class B : public A {
public:
int boo(int a) { return a; }
};
int main() {
B *b = new B();
B bb;
cout << "Blah: " << b->boo() << endl;
cout << "Blah: " << bb.boo() << endl;
delete b;
return 0;
}
Problem
-------
The compiler reports an error probably because it doesn't
recognize that the reference b->boo() is to a function from the
superclass A, and not an erroneous attempt to use a function from
B.
Were the function int B::boo(int) not defined, the code would compile.