title: Implementation of destructor as a function?
body: <p>I have a question about a destructor's implementation for a class. I understand the right way is using the ~ operator, but take a look at the following code:</p>
  
  <pre><code>class foo
  {
  private:
  int* abc;
  
  public:
  foo()
  {
  abc = new int(2);
  }
  
  ~foo()
  {
  delete abc;
  }
  
  void func()
  {
  delete abc;
  }
  }
  </code></pre>
  
  <p>Now let us say that the main function is defined as below:</p>
  
  <pre><code>int main(int argc, char** argv)
  {
  foo a;
  a.func();
  }
  </code></pre>
  
  <p>Upon the function call of func() in main, does this work in the exact same way as the destructor? What is the difference between the destructor and this function in any similar setting?</p>