CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 36

Threaded View

  1. #31
    Join Date
    Jan 2009
    Posts
    1,689

    Re: delete[] mechanics

    Don't have to call destructors on primitives.

    Code:
    char * array = new char[5];
    delete[] array;
    No dtors.

    Also, you don't need to know the number of elements to call of the destructors. You can easily determine that by total_allocated_space / sizeof(element). In fact, the iterating is probably done by using a running pointer, not an index anyway. My guess is that most compilers record the size of the space, not the number of items, because in the end, new[]/delete[] uses malloc / free. free doesn't care how many items is in it, just how many bytes.
    Last edited by ninja9578; July 13th, 2010 at 02:37 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured