title: When is an object "out of scope"?
body: <p>In C++, when is an object defined as "out of scope"? </p>
  
  <p>More specifically, if I had a singly linked list, what would define a single list node object as "out of scope"? Or if an object exists and is being referenced by a variable <code>ptr</code>, is it correct to say that the object is defined as "out of scope" the moment the reference is deleted or points to a different object?</p>
  
  <p>UPDATE: Assuming an object is a class that has an implemented destructor. Will the destructor be called the moment the object exits the scope?</p>
  
  <pre><code>if (myCondition) {
      Node* list_1 = new Node (3);
      Node* list_2 = new Node (4);
      Node* list_3 = new Node (5);
  
      list_1-&gt;next = list_2;
      list_2-&gt;next = list_3;
      list_3-&gt;next = null;
  }
  </code></pre>
  
  <p>In other words, would the Node being pointed to by <code>list_1</code> call its destructor after this line: </p>
  
  <pre><code>Node* list_1 = new Node (3);
  </code></pre>
  
  <p>?</p>