Consider a class 'B' that contains simple char member vars in a certain order.
class B {
char x1;
char x2;
char x3;
char x4;
}
I have a buffer A that already contains data in the same order as defined in B. Another process has already loaded A with the data.
char A[4];
Is it possible to construct an object of type
Bthat contains the data ofA, without the constructor copying the data? That is, I want to "overlay" aBobject onto theAbuffer so I can useBmethods on the data, without incurring the overhead of a copy, or the allocation of memory.Assuming there is a solution to question 1, would there be any reason I couldn't also define a class
Dthat derives fromBand which has methods that reference the member vars ofB, but which itself contains no new member variables?