title: Serializing object to byte-array in C++
body: <p>I am working on an embedded device (microcontroller), and I want to save objects to permanent storage (an EEPROM). Most of the serialization solutions I can find, use the file-system in some way, but my target has no file-system. </p>
  
  <p>Therefore my question is, how can I serialize an object to a byte-array so I can save that byte-array to an EEPROM afterwards? </p>
  
  <p>Here is an example of what i am trying to do: </p>
  
  <pre><code>class Person{
       //Constructor, getters and setters are omitted
  
      void save(){
           char buffer[sizeof(Person)]; 
           serialize(buffer);
           EEPROM::Save(buffer, sizeof(Person)); 
      }
  
      void load(){
           char buffer[sizeof(Person)]; 
           EEPROM::Load(buffer, sizeof(Person));
           deserialize(buffer);
      }
  
      void serialize(char* result){
          //?????
      }
  
      Person deserialize(char* buffer){
          //??????
      }
  
  private:
      char* name;  
      int   age; 
      float weight; 
  };
  </code></pre>