[Bug c++/13937] New: virtual method hides overloaded method in base class
msieweke at broadcom dot com
gcc-bugzilla@gcc.gnu.org
Fri Jan 30 19:33:00 GMT 2004
// Just any old forward declaration.
class Thingy;
// Base class A stores a pointer to an object of type Thingy, and provides
// accessors to set and get the pointer.
class A
{
public:
A(void) {}
virtual ~A() {}
public:
virtual void Value(Thingy *pThingy);
Thingy *Value(void) {return pfMyThingy;}
private:
Thingy *pfMyThingy;
};
// Derived class B overrides the accessor method in the base class so that it
// can do something special when a Thingy is being set.
class B : public A
{
public:
B(void) {}
virtual ~B() {}
public:
virtual void Value(Thingy *pThingy);
};
// This function tries to get hold of the Thingy object, which should resolve
// to A::Value(void); however, the compiler seems unable to make this
// connection.
void MyFunction(void)
{
B *pMyB = new B;
Thingy *pThingy;
pThingy = pMyB->Value();
}
/*
This is the error produced by the above code:
../bug.cpp: In function `void MyFunction()':
../bug.cpp:48: no matching function for call to `B::Value()'
../bug.cpp:35: candidates are: virtual void B::Value(Thingy*)
If we change the code to:
pThingy = ((A *) pMyB)->Value();
it will compile without complaint.
*/
// NOTE: This may be related to bug #13590
// Bug duplicated with G++ 3.3.2 and 3.2.1
--
Summary: virtual method hides overloaded method in base class
Product: gcc
Version: 3.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: msieweke at broadcom dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i386-gnu-linux
GCC target triplet: mipsisa32-elf
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13937
More information about the Gcc-bugs
mailing list