ask for advices

I want to get a backup of a object. So, I was going to write a copy constructor for the class to copy this object to a backup one. But I found several raw pointer members in that class. Thus, implementing a copy constructor would be as hard as implementing a smart pointer. Besides, the class is too old and complex to be rewritten. Is there another way to achieve the backup task of the object besides implementing copy constructor?
Is there specific state that you wish to back up? Can you store only some of the object's state or do you need to store all of it?
Can you make a new class, inherit the old class and add data memebers to store the state of the objects the pointers are referencing?

Would it be easier to just save a raw copy of the memory heap? This would be library dependent but I know Win32 has a couple functions to accomplish this. Which libs are you using?
1
2
3
4
5
6
7
8
9
 
SomeClass & SomeClass(const SomeClass & oldObject){ // this also work with assigment operator
   member = oldObject.member; // assigment operator
   // or
   member(oldObject.member) // copy constructor
  // or pointers
  member = new SomeMember();
  member* = (oldObject.member)*;
}


If the member types are primitive types or classes it should work just fine because they will generate a copy-constructor ( see rule of three) if the members are pointers you have to copy the content of that pointer. using either operator * or operator ->.
Thank you all for kindly helps. I find that serialization of boost library may work in my sitution. Thanks
Topic archived. No new replies allowed.