Or how to modify A_type so that it works as B_type?
Code: Select all
type big_type
dim as integer number(999)
end type
'Option A
type A_type
dim as big_type big
declare constructor(byref big as big_type)
end type
constructor A_type(byref big as big_type)
this.big = big '<-- makes a full copy of big
end constructor
'Option B
type B_type
dim as big_type ptr pBig
declare constructor(pBig as big_type ptr)
end type
constructor B_type(pBig as big_type ptr)
this.pBig = pBig '<-- does not make copy
end constructor
'use it
dim as big_type big
big.number(3) = 111
var A = A_type(big)
var B = B_type(@big)
print A.big.number(3)
print B.pBig->number(3)
print
big.number(3) = 555 'change
print A.big.number(3), "<-- Not changed because a copy was made"
print B.pBig->number(3)