title: Is it possible to dereference an object to another object inside his own method?
body: <p>I have a question about some C++ problem. Let's say I have a really big class called <code>BigClass</code> and I say <code>BigClass* foo = new BigClass();</code></p>
  
  <p>Let's say I have a method inside BigClass that defines another local object <code>tmp</code> of type BigClass and at the end of the method, I check if there was the error by doing some stuff with <code>tmp</code> and if not I want to dereference <code>this</code> to that object. I don't want to copy all the arguments from <code>tmp</code> to <code>this</code>, because the object is too big and the process would be slow. Is there any way to dereference the object inside its own method?</p>
  
  <p>Example:</p>
  
  <pre><code>class BigClass
  {
      int a;
      long b;
      std::vector&lt;int&gt; c;
      // other members...
  
      void replace()
      {
          BigClass* tmp = new BigClass();
          // do some calculations with tmp
          *this = tmp; // problem
      }
  }
  </code></pre>
  
  <p><strong>Why is *this = tmp a problem?</strong></p>
  
  <p>I defined an operator= that just does something like this:</p>
  
  <pre><code>this.a = src.a;
  this.b = src.b;
  this.c = src.c;
  .
  .
  .
  </code></pre>
  
  <p>But there I make a copy of all member variables and that is slow. I want to simply dereference the object instead of copying all member variables.</p>