This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Deleting a virtual base class pointer gives segmentation fault.
- To: Fredrik Öhrström <d92-foh at nada dot kth dot se>
- Subject: Re: Deleting a virtual base class pointer gives segmentation fault.
- From: Nathan Sidwell <nathan at acm dot org>
- Date: Mon, 11 Oct 1999 14:13:26 +0100
- CC: gcc-bugs at gcc dot gnu dot org
- References: <Pine.GSO.3.95.991011143630.9506A-100000@mumrik.nada.kth.se>
- Reply-To: nathan at compsci dot bristol dot ac dot uk
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