Deleting a virtual base class pointer gives segmentation fault.

Nathan Sidwell nathan@acm.org
Mon Oct 11 06:19:00 GMT 1999


Fredrik Vhrstrvm wrote:
> 

> int main ()
> {
>         Alfa *a = new Alfa_i;
>         delete a;
> }
> --------------------------------------------------------------
> 
> Am I not allowed to delete virtual base class pointers? 
Your base class Alfa is not polymorphic, therefore it won't work.
You need to either
1) make Alfa polymorphic (add virtual functions, probably the dtor)
2) make a and Alfa_i pointer.

nathan

-- 
Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP
nathan@acm.org  http://www.cs.bris.ac.uk/~nathan/  nathan@cs.bris.ac.uk


More information about the Gcc-bugs mailing list