Boost logo

Boost Users :

From: Anna Kloper (annakloper_at_[hidden])
Date: 2006-09-25 02:36:58


Hi all,
  I'm new to BOOST and need help with this kind of problem of pointers serialization:
   
  class A{
  public:
  A(int *anInt):m_pi(anInt){}
  ~A(){}
  private:
  int *m_pi;
  };
   
  class B{
  public:
  B(int *anInt):m_a1(anInt),m_a2(anInt){}
  ~B(){}
  private:
  A m_a1;
  A m_a2;
  };
   
  int main()
  {
  int i=1;
  B b(&i);
  //serialize b
   
  i=2;
  //serialize b
   
  //de-serialize b expected i = 1 and b.m_a1=b.m_a2=1
  //de-serialize b expected i = 2 and b.m_a1=b.m_a2=2
   
  }
   
   
   
  Now, assuming that there are serialization functions for class A and B I'd like to serialize object b swice with track never so that when de-serializing b I'd like b to contain a pointer to the location of i. The problem is that when I de-serializing b I notice that b doesn't pointer to the location of i anymore but to another location.
  I need this for serializing of communication, so I need to save all the data trough a pointer and read the data back step by step for preprocessing to the same location in the memory.
   
  Is there anything I can do to overcome this problem with pointers?
   
  Thank you in advance, Anna.

                 
---------------------------------
Do you Yahoo!?
 Everyone is raving about the all-new Yahoo! Mail.



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net