Accessing field in parent object ?
BlitzMax Forums/BlitzMax Programming/Accessing field in parent object ?
| ||
| Hello there, Type TBigObject Field Smaller_Object:TSmallObject Field Some_Variable:int = 15 End Type Type TSmallObject Method Do_Something() ???????????? End Method End Type Let's say that I create an instance of a TBigObject, which contains itself an instance of SmallObject in it field called "Smaller_Object". Is it possible then for Smaller_Object to access a field in its parent object, for example, I would like the Do_Something() method to access "Some_Variable". Thank you |
| ||
| No, not directly. You either need to give TSmallObject a reference to its parent. Or set a pointer to the integer when you create it. EG:
Type TBigObject
Field Smaller_Object:TSmallObject
Field Some_Variable:int = 15
Method New()
Smaller_Object=New TSmallObject
Smaller_Object.Pointer = VarPtr(Some_Variable)
End Method
End Type
Type TSmallObject
Field Pointer: Int Ptr
End Type
|
| ||
| Great! Thanks a lot. |