Hi,
I have following two classes
class base{
int i;
public:
virtual void fun() { cout<<i<<"Base \n"; }
};
class d: public base{
int j;
public:
void fun() { cout<<"Derived \n"; }
};
and the code is doing something like this.
d d1;
char c[100];
bcopy((char *)&d1, c, sizeof(d));
factory->process(c); // some factory member which accepts a char *
// Inside factory->process ()
d *dp=reinterpret_cast<d *(c);
dp->fun();
Question: Is it ok to copy an object to a char array and cast it back
like this. Can there be any memory alignment problem (on a single
processor only). Or any other problem.