This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
egcs-1.1 and virtual method questions
- To: <egcs-bugs at cygnus dot com>
- Subject: egcs-1.1 and virtual method questions
- From: Gilles Depeyrot <Gilles dot Depeyrot at wanadoo dot fr>
- Date: Wed, 18 Nov 98 21:00:09 +0100
Hello everyone,
I have a question concerning egcs 1.1 and virtual methods. There
may be a bug in egcs but I need more background.
In a 20K+ pile of C++ code which I am supposed to maintain (I didn't
write the stuff), I have a problem with virtual methods not acting
as expected.
Given the base class:
class foo {
public:
foo();
~foo();
virtual bool do_something();
};
and the class:
class foobar : public foo {
public:
foobar();
~ foobar();
bool do_something();
};
You can notice that the virtual method of class foo is overridden in
class foobar but is *not* declared as virtual.
If I manipulate objects of class foobar with a foo pointer, which method
should be called for do_something ?
Shouldn't the compiler emit a warning because do_something is overridden
but not declared virtual ?
In my code, with an object of class foobar manipulated with a foo pointer,
the do_something method which is effectively called is foo's do_something
instead of foobar's do_something !
Thanks for your help,
Gilles Depeyrot
Gilles Depeyrot <mailto:Gilles.Depeyrot@wanadoo.fr>
<http://perso.wanadoo.fr/gilles.depeyrot>