Reference Integer?

BlitzMax Forums/BlitzMax Programming/Reference Integer?

BLaBZ(Posted 2010) [#1]
Is there a way to reference an integer? So if the main integer changes so does the other?!


Jesse(Posted 2010) [#2]
not two variable with the same address but pointer-wise yes:
SuperStrict
Local a:Int = 100
Print "a =" + a

Local b:Int Ptr = Varptr(a)
Print "b pointer =" +b[0]
b[0] = 50

Print "b = 50 -> a = "+ a

or in a function:
a = 50 
change(a)
Print a

Function change(b:Int Var)
	b = 20
End Function 



Czar Flavius(Posted 2010) [#3]
Type TInt
	Field value:Int
	
	Function Create:TInt(value:Int)
		Local i:TInt = New TInt
		i.value = v
		Return i
	End Function
End Type

Local first:TInt = TInt.Create(5)
Local second:TInt = first
second.value = 10
Print first.value