Article View: gnu.g++.bug
Article #1707g++ compiler problem - virtual fns with derived class args
From: Tim Day
Date: Fri, 24 Feb 1989 13:21
Date: Fri, 24 Feb 1989 13:21
44 lines
1338 bytes
1338 bytes
Here's a good 'un.... It compiles OK under Glockenspiel C++, but under
g++ (g++ version 1.32.0) I get :
vtest.cc:17: conficting specification deriving from virtual
function `void One::scooby (struct Foo &)'
vtest.cc:27: warning: excess elements in aggregate initializer
--------------------------------------------------------------
class Foo
{
public:
Foo() {}
};
class Bar : public Foo
{
public:
Bar() :(){}
};
class One
{
public:
One() {}
virtual void scooby(Foo&) {} // Here
virtual void scooby(Bar&) {}
};
class Two : public One
{
public:
Two() :(){}
virtual void scooby(Foo&) {}
virtual void scooby(Bar&) {}
}; // and here
main()
{ One a;Two b;
a.scooby(Foo());a.scooby(Bar());b.scooby(Bar());b.scooby(Foo());
exit(0);
}
-----------------------------------------------------------------
The problem goes away if class Bar is NOT derived from class Foo.
Tim
Technical Details
Message-ID:
<8902241307.AA19473@prep.ai.mit.edu>Path:
arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!PURPLE.CS.UCL.AC.UK!T.DayShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!tut.cis.ohio-state.edu!PURPLE.CS.UCL.AC.UK!T.Day From: T.Day@PURPLE.CS.UCL.AC.UK (Tim Day) Newsgroups: gnu.g++.bug Subject: g++ compiler problem - virtual fns with derived class args Message-ID: <8902241307.AA19473@prep.ai.mit.edu> Date: 24 Feb 89 13:21:55 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 44