title: C++ call delete does not free memory?
body: <p>I want to test what delete in c++ can do so wrote the following:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  class A{
  public:
    A(string s):a(s){}
    string getS(){
      return a;
    }
  private:
    string a;
  };
  
  class B{
  public:
    B(string str):s(str){}
    void setV(A a){
      v.push_back(a);
    }
    string getS(){
      return s;
    }
  private:
    vector&lt;A&gt; v;
    string s;
  };
  
  int main(){
    A a("abc");
    B* b = new B("cba");
    b-&gt;setV(a);
    cout&lt;&lt;b-&gt;getS()&lt;&lt;endl;
    cout&lt;&lt;a.getS()&lt;&lt;endl;
    delete b;
    cout&lt;&lt;b-&gt;getS()&lt;&lt;endl;
    cout&lt;&lt;a.getS()&lt;&lt;endl;
    return 0;
  }
  </code></pre>
  
  <p>And I still got the following output:</p>
  
  <pre><code>cba
  abc
  cba 
  abc
  </code></pre>
  
  <p>looks like I can still get access the memory for both a and b?
  So my question would be
  1.Why do I have access to b, since I have called delete on it?
  2.Why do I have access to a, since b's destructor is called so the memory of vector containing a should be free?</p>
  
  <p>Cheers </p>