I'm using union that have 2 members. One's type is QByteArray, other's *double. I want to access QByteArray members after changing value of the double array.
I've tried this using with char * (size = 8) and double union members. There was no problem.
union smt{
QByteArray qbyte;
double *data;
~smt(){} // needs to know which member is active, only possible in union-like class
};
smt x={"sometng"};
double *result =...;
memcpy(x.data,result,sizeof (double)); // copy result to x.data
In this code I want to access the values of the QByteArray after changing the data array. Basically I want to get the string values corresponding the double values. If they are sharing the same memory space, theoretically it's possible, right?
However, after changing the data array, I got runtime error, that says the QByteArray "not accessible"
Am I missing something or doing smtg wrong? Please help me
Thank you, in advance
Aucun commentaire:
Enregistrer un commentaire