Class in a Class Memory Exception

BlitzMax Forums/BlitzMax Beginners Area/Class in a Class Memory Exception

Aeronux(Posted 2007) [#1]
Hmm. I'm using the demo, and I am trying to include an object inside an object. When I try to compile this though, it gives me a memory exception error...

help, please??

	SuperStrict
	
	'armor protects
	Type Armor	
		Field iLight:Int
		Field iHeavy:Int	
		Method New()		
			iLight = 0
			iHeavy = 0;	
		End Method	
	End Type
	
	Type Unit 	
		Field armor:Armor = New Armor ' <- errorrrr		
		Method New()				
			armor.iLight = 	0
			armor.iHeavy = 	0
		End Method	
	End Type
	
	Type Unit_Infantry Extends Unit	
		Method New()
			armor.iLight = 	4
			armor.iHeavy = 	2			
		End Method	
	End Type
	
	Global UNITS_INFANTRY:Unit_Infantry = New Unit_Infantry	
	Print UNITS_INFANTRY.armor.iLight



Dreamora(Posted 2007) [#2]
the problem is that the variable has the same name as the class -> no go

BM is not case sensitive, just to mention that.


Aeronux(Posted 2007) [#3]
o.o ... Well, then that makes sense :P

thanks!


SculptureOfSoul(Posted 2007) [#4]
Yup, it's usually a good idea to tack a "T" in front of your type name (i.e. TArmor, TUnit, etc)