title: What is wrong with this operator overloading code?
body: <p>What is wrong with this c++ code?</p>
  
  <p>It compiles, but, it doesn't run.</p>
  
  <pre><code>    #include &lt;iostream&gt;
  
  using namespace std;
  
  class MyClass
  {
  private:
      int *x;
      int *y;
  public: 
      MyClass()
      {
          x = new int[1]; *x = 0;
          y = new int[1]; *y = 0;
      }
      ~MyClass()
      {
          if(x != NULL)
          {
              delete [] x;
              x = NULL;
          }
          if(y != NULL)
          { 
              delete [] y;
              y = NULL;
          }
      }
      MyClass operator=(MyClass &amp; rhs)
      {
          MyClass temp;
          temp.Set(rhs.x[0], rhs.y[0]);
          return temp;
      }
      void Set(int a, int b)
      {
          if(x != NULL)
          {           
              *x = a;
          }
          if(y != NULL)
          {           
              *y = b;
          }
      }
      void Show()
      {
          cout&lt;&lt;x[0]&lt;&lt;y[0]&lt;&lt;endl;
      }
  };
  
  int main()
  {
      MyClass o1;
      o1.Set(10, 20);
      o1.Show();
  
      MyClass o2;
      o2 = o1;
      o2.Show();
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/XFde1.jpg" alt="enter image description here"></p>