Having something like the following code (simplified):
struct MyStruct {
int member1;
int member2;
};
class MyClass {
MyStruct *data;
}
MyClass obj;
// put obj.data in pstruct
// so obj.data->element1 is the same as pstruct->element1
MyStruct *pstruct = obj;
I don’t want to create a copy of obj.data but return the same pointer so if i make a change in pstruct->member1 the change is the same in obj.data->element1 (and the opposite).
Is this possible?
Thanks
Sounds like you want a conversion operator that creates a
MyStruct*from aMyClass: