Original Post
Can I do this safely? Since the class object only owns the data member, and belongs to no hierarchy, is it safe to assume the data member is the only memory it owns? Is it safe to assume PtrThing is synonymous with int* ? edited: I forgot my reference (&) operators. [Edited by - Kest on October 11, 2006 3:57:59 AM]
class PtrThing
{
PtrThing() { data = new int[**]; }
~PtrThing() { delete [] data; }
... big interface ...
static const PtrThing& GetTempInterface(const int* &d) { return *((PtrThing*)&d); }
private:
int *data;
};
...
int *custom_data = GetCustomData(..);
const PtrThing &ref20 = PtrThing::GetTempInterface( custom_data + 20 );