I have a class sample as:
class sample{
public:
    sample(){
        sample_name=new char[10];
    }
    int sample_num;
    float sample_wt;
    char *sample_name;
};
Its object is created and values are accesed as folllows:
sample *object= new sample();
object->sample_num=10;
object->sample_wt=20.02;
object->sample_name="test";
My question is as follows:
How will i create a buffer which contains all the information stored inside object? I tried doing this as follows:
char * buffer = new char[256];
buffer =  reinterpret_cast <char *> ( object );
Now,what i see is the object do consists of all the three values of sample_num, sample_wt and sample_name but these values are not passed to buffer,buffer shows garbage values.
So, how will i get these values inside the buffer?
 
     
     
     
     
    