title: Why can freed dynamically allocated memory still be accessed after a delete operation in C++?
body: <p>Suppose I have allocated some memory for storing an int value like this:</p>
  
  <pre><code>int *p=new int; 
  </code></pre>
  
  <p>Here I created the required memory using <code>new</code> operator and assigned the address of that memory block so that I can access that memory block.</p>
  
  <p>Now it's my control to what I store in that memory block.</p>
  
  <p>But when I write a statement like this: </p>
  
  <pre><code>delete p;
  </code></pre>
  
  <p>we say that I have deleted the dynamically allocated memory.</p>
  
  <p>But if I really <code>delete</code>'d or freed up that memory, should I not be able to access that memory anymore after the <code>delete</code> operation? But I was able to access that memory block using the same pointer variable. So what was the purpose of deleting the memory block if we can access the block after deleting it?</p>
  
  <p>Here's some sample code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main(void)
  {
      int *p;
      p=new int;
      *p=10;
      cout &lt;&lt; *p &lt;&lt; endl;
      delete p;
  
      //here look we can still access that block of memory using the same pointer variable
      //But we did not created the  memory block after deletetion
      cout &lt;&lt; *p &lt;&lt; endl;
      *p=20;
      cout &lt;&lt; *p &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>What does the saying "deleted/ free up the dynamically allocated memory" means in this context?</p>