Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Tim Day
Fri, 24 Feb 1989 13:21
g++ compiler problem - virtual fns with derived class args
Author: 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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads