[comp.lang.c++] Problem on virtual function.

laucy@warwick.ac.uk (TS Wong) (04/14/90)

The compiler give me a strange error message (I haven't acturally got
any constructor inside the class definition.) when I compile the
following code. The message will disappear if the virtual declaration is
removed. Is it a bug, or when we declare a virtual function a
invisibly constructor is created? Can anyone told me why?

Thanks in advance.

N.B. I'm using AT&T C++ Ver.2.0
CC  t.c:
"t.c", line 10: error:  member c::test of class a with constructor in union
1 error

---------------------------------
#include <stream.h>
class a {
public:
    virtual void test() {
	cout << "Hello" ;
    }
} ;

union c {
    a test ;
} ;

main()
{
    c f ;
}

-------------------------------
laucy@uk.ac.warwick.cu