When writing a custom assignment operator, is there a caveat to first copying the whole object with a memcpy rather than tediously field by field, and then fixing the pointers and such? This is what I mean:

Qt Code:
  1. MyObject& MyObject::operator=(const MyObject &o)
  2. {
  3. memcpy(this, &o, sizeof(MyObject)); // Copy everything in one go.
  4.  
  5. // Do other things like fix pointers.
  6.  
  7. return *this;
  8. }
To copy to clipboard, switch view to plain text mode