CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2008
    Posts
    1

    a question about "delete"

    I create 2 pointers to the same point. What happen when I use "delete" with the first pointer? Is the content of the second pointer detroyed?

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: a question about "delete"

    Yes but not the pointer itself (neither the first, nor the second) so after the delete both pointers points to invalid memory space.

  3. #3
    Join Date
    Sep 2007
    Location
    poland|wrocław
    Posts
    47

    Re: a question about "delete"

    Next delete on second pointer should caous an exception. That why people discover smart pointers or auto pointers.

  4. #4
    Join Date
    Apr 2004
    Location
    England, Europe
    Posts
    2,492

    Re: a question about "delete"

    macabre13, no the next delete on second pointer will cause undefined behaviour.
    My hobby projects:
    www.rclsoftware.org.uk

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