This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about -fall-virtual
- To: egcs at cygnus dot com
- Subject: Question about -fall-virtual
- From: Fredrik Öhrström <d92-foh at nada dot kth dot se>
- Date: Sun, 21 Jun 1998 19:03:04 +0200 (MET DST)
Have I misunderstood the -fall-virtual switch purpose?
I thought that it would do:
treat every member function as virtual, even if they are not
prefixed by "virtual".
However the following simple code:
#include<iostream.h>
struct A
{
int hi () { return 0; }
};
struct B : public A
{
int hi () { return 4; }
};
int main ()
{
A *a = new B;
cout << a->hi () << endl;
}
Compiled with -fall-virtual (egcs1.0.3) still prints the answer 0.
When I do as I should do according to the standard (that is prefix A::hi with
virtual), it prints 4 like it should.
I just want to get rid of the virtual prefix since all my classes are
virtual and -fall-virtual seemed like a good idea. :-)
What am I doing wrong? Any help greatly appreciated.
//Fredrik