title: Destructor gets called before the end of scope
body: <p>for some reason, after creating an object in main func., the destructor gets called right away, isn't it supposed to get called only when main finishes? thanks</p>
  
  <p>code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;vector&gt;
  using namespace std; 
  
  
  class check{                                                   //create class check
  public:
      string m_bank_name;
      int m_check_number;
      int m_branch_number;
      char* m_check_sum;
  
  
  
      check ( string bank_name, int check_number, int branch_number, char* check_sum){
          int a_size = (strlen(check_sum)+1);
          m_check_sum = new char[a_size]();
          for (int i=0;i&lt;a_size;i++)
          {
              m_check_sum[i]=check_sum[i];
          }
          m_bank_name= bank_name;
          m_check_number = check_number;
          m_branch_number = branch_number;
      }
  
      ~check (){
          delete [] m_check_sum;
          cout&lt;&lt;"deleted!"&lt;&lt;endl;     
          }
  };
  
  void main(){
  
      check ob1= check("poalim",809877,12,"4578");
      cout&lt;&lt;ob1.m_check_sum&lt;&lt;endl;
      getchar();
  }
  </code></pre>