CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2000
    Location
    Norway
    Posts
    13

    delete vs. delete []

    Hi,

    Does anyone know if there is possible to decide in runtime either to call:


    delete someptr;




    or


    delete [] someptr;




    What about smart pointers? How do they know which one to call?



    Kjetil Haga


  2. #2
    Join Date
    Dec 2000
    Location
    Norway
    Posts
    13

    Re: delete vs. delete []

    Hi again...

    I've taken a look at boost and they have a separate smart pointer for arrays (shared_array). Since the boosters have made a separate class for handling dynamic arrays, I guess this is not possible. Please correct me if I'm wrong....

    Thanks.



    Kjetil


  3. #3
    Join Date
    Oct 2000
    Location
    London, England
    Posts
    4,773

    Re: delete vs. delete []

    the solution is never to use arrays and then you need never use delete []

    use std::vector instead of arrays.


    The best things come to those who rate

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