Re: Segfault with delete[] operator & virtually derived classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



JP Mercury wrote:

main() {
  A *list = new B[10];      // Allocate 10x derived, store first in A *list
this won't work. new B[10] gets you an array of 10 B objects, you can't
expect that to look like an array of A objects.

you should use an array of pointers to object -- or some container
object.

nathan

--
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
nathan@xxxxxxxxxxxxxxxx    ::     http://www.planetfall.pwp.blueyonder.co.uk


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux