title: C++: why it doesn't call a destructor?
body: <p>I use extra brackets in my code. I thought when the destructor should be called after the local variable scope is ended but it doesn't work like this:</p>
  
  <pre><code>class TestClass {
  public:
      TestClass() {
          printf( "TestClass()\n" );
      }
      ~TestClass() {
          printf( "~TestClass()\n" );
      }
  };
  
  int main() {
      int a, b, c;
      {
           TestClass *test = new TestClass();
      }
  }
  </code></pre>
  
  <p>It outputs:</p>
  
  <blockquote>
    <p>TestClass()</p>
  </blockquote>
  
  <p>So it doesn't call the destructor of the TestClass but why? If I call it manually (delete test) it calls the destructor, right. But why it doesn't call the destructor in the first case?</p>