I want my type to extend two types

BlitzMax Forums/BlitzMax Programming/I want my type to extend two types

JoshK(Posted 2006) [#1]
Is there any way to make a type extend two different types, or do I have to arrange them in a stack, so that my type extends one type, which in turn extends the other type?


Leiden(Posted 2006) [#2]
Nah you cant unfortunately :( A Stack is probably the best way to go.


Scott Shaver(Posted 2006) [#3]
The other option is to simply use composition. Extend from one type and have a field of the other type.


morszeck(Posted 2006) [#4]
It is not mad, but it runs:

Strict

Type t1
	Field a
	Method geta()
		Return a
	End Method
End Type

Type t2
	Field b
	Method getb()
		Return b
	End Method
End Type

Type comb
	Global t1:t1 = New t1
	Global t2:t2 = New t2
End Type


Local my:comb = New comb

my.t1.a = 10
my.t2.b = 20

Print "> "+ my.t1.geta()
Print "> "+ my.t2.getb()


Or, which I make:

Strict

Type t1
	Field a
	Method geta()
		Return a
	End Method
End Type

Type t2 Extends t1
	Field b
	Method getb()
		Return b
	End Method
End Type


Type t3 Extends t2
	Field c
	Method getc()
		Return c
	End Method
End Type


Local my:t3 = New t3

my.a = 10
my.b = 20
my.c = 30

Print "> "+ my.geta()
Print "> "+ my.getb()
Print "> "+ my.getc()



boomboommax(Posted 2006) [#5]
do the above