title: How to detect if a pointer was deleted and securely delete it?
body: <p>In <strong>C++</strong> How to decide or know if a pointer was deleted before??</p>
  
  <p>when i tried to delete a pointer that was previously deleted in another part of the code it threw an exception that can't be handled.</p>
  
  <p>I was wondering if there is a way to check or try delete the pointer ? any reference about advanced memory operations.</p>
  
  <p>also i want to master the un-handled exceptions of pointers and the access to protected or access is violation ,... this kind of error.</p>
  
  <p>thanks for those who give some of their knowledge and their time to help other people and share their benfits</p>
  
  <hr>
  
  <h1>Update</h1>
  
  <p>The big advice from a lot of modern c++ developers community is - Use smart pointers or try to avoid the use of raw pointers. But for throw security and insuring free of memory (<a href="https://isocpp.org/wiki/faq/exceptions#ctors-can-throw" rel="noreferrer">ISO_CPP_FAQ</a>) and of course if you want to avoid the small overhead of using smart pointers[may not be noticeable always but they have overhead] you can write your custom methods that deal with raw pointers [type*] - this is not general. 
  <strong>Prefer always smart pointers to raw pointers</strong>.</p>
  
  <p>In 'Going Native 2013' a common advice given was - Never use raw pointers.</p>