title: how to return the result of addition of two objects of a class
body: <p>On compiling it is showing <code>sme error</code> like use of delete function <code>constexpr Player::Player(const Player&amp;)</code> when it is return the result of addition of the objects.</p>
  <pre><code>#include &lt;bits/stdc++.h&gt;
  
  using namespace std;
  
  class Player
  {
    char* name;
    int num;
  
   public:
    Player(char* str = nullptr, int n = -1)
        : name{str}
        , num{n}
    {
      if (str != nullptr)
      {
        name = new char[strlen(str) + 1];
        strcpy(name, str);
        str = nullptr;
      }
    }
  
    Player&amp; operator=(const Player&amp; temp)
    {
      delete[] this-&gt;name;
      this-&gt;name = new char[strlen(temp.name) + 1];
      strcpy(this-&gt;name, temp.name);
      this-&gt;num = temp.num;
    }
  
    Player operator+(const Player&amp; temp);
  };
  
  Player Player::operator+(const Player&amp; temp)
  
  {
    char* str = new char[strlen(name) + strlen(temp.name) + 1];
  
    strcpy(str, name);
    strcat(str, temp.name);
  
    int n = num + temp.num;
  
    Player result{str, n};
  
    delete[] str;
  
    return result;
  }
  
  int main()
  
  {
    Player p1{&quot;abc&quot;, 11};
    Player p2{&quot; xyz&quot;, 9};
    Player p3;
  
    p3 = p1 + p2;
  }
  </code></pre>