Extended Types and Global Lists

BlitzMax Forums/BlitzMax Beginners Area/Extended Types and Global Lists

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I'm extending a base class and I want each class to have it's own list of objects. But obviously there's not much point having a base class if I have to do everything in relation to the list separately for each type.

Quick example code

Type A
	
	Global List:TList
	
	Method New()
		
		If List=Null
			List=New TList
		End If
		ListAddLast List,Self
		
	End Method
	
	
End Type



Type B Extends A
	
End Type


Type C Extends A
	
End Type



Global AB=New B
Global BB=New B
Global CB=New B

Global AC=New C
Global BC=New C
Global CC=New C



Now if I try to examine the list from any of the types, it's all the same list, with 6 objects, 3 of each. What I'd like is for C to have a list of three C's and B to have a list of 3 B's. But I still want to be able to operate with the list in the base class. Hope that makes sense.

I'll be having an awful lot of extended types and it will be a huge amount of extra code if I can't extend a base type. They all have so much in common that it really ought to be a huge saving, if I could just get lists behaving as I want.

Suggestions?