This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Deleting a virtual base class pointer gives segmentation fault.


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]