title: Will this lead to a memory leak in C++?
body: <p>I have a C++ memory management doubt, that's (obviously) related to references and pointers. Suppose I have a class <code>Class</code> with a method <code>my_method</code>:</p>
  
  <pre><code>OtherClass&amp; Class::my_method( ... ) {
      OtherClass* other_object = new OtherClass( ... );
      return *other_object;
  }
  </code></pre>
  
  <p>Meanwhile in a nearby piece of code:</p>
  
  <pre><code>{
      Class m( ... );
      OtherClass n;
      n = m.my_method( ... );
  }
  </code></pre>
  
  <p>So, I know that there's a general rule about pointers (~ "anything new-ed, must be delete-d") to avoid memory leaks. But basicly I'm taking a reference to my heap-allocated object, so when n goes out of scope, shouldn't the destructor of OtherClass be called thus freeing the memory previously pointed by other_object?
  So in the end the real question is: will this lead to a memory leak?</p>
  
  <p>Thanks.</p>