title: Why I don't get a dangling pointer?
body: <p>Why I is the output of the following code <code>10</code> and not an error? Isn't <code>object2</code> a dangling pointer?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  
  int *method()
  {
    int object = 10;
    return &amp;object;
  }
  
  
  int main()
  {
      int *object2 = method();
  
      cout &lt;&lt; *object2;
  }
  </code></pre>
  
  <p>Thanks!</p>