title: C++ compiler warning - returning local variable
body: <p>I'm simply trying to overload a + operator and I'm getting this compiler warning</p>
  
  <pre><code>reference to local variable 'tmp' returned
  </code></pre>
  
  <p>Here is the code for the overload</p>
  
  <pre><code>const Int&amp; Int::operator+(const Int&amp; p) const
  {
      Int tmp = value + p.value;
      return tmp;
  }
  </code></pre>
  
  <p>Here is the class</p>
  
  <pre><code>class Int{
      int value;
  public:
      Int() {}    // default constructor
      Int(int v) : value(v) {}
      Int&amp; operator=(const Int&amp;);
      const Int&amp; operator+(const Int&amp;) const;
  };
  </code></pre>