Object confusion
BlitzMax Forums/BlitzMax Beginners Area/Object confusion
| ||
Ok another noob question here...p:player = new player players = new tlist (Now load all players into the players list) deadplayers = new tlist function killplayer() local pl:player for pl = eachin players if pl.cond$ = "dead" then deadplayers.addlast pl end if next end function Ok here is the question, how many copies of pl do I have? When the player dies I want to move it over to the dead players list. If I do not remove it from the first list which scenario do I have: (1) Two copies of PL that can be independantly modified (2) One copy of PL that is refferenced in both lists Thanks all! |
| ||
2)One copy of PL that is refferenced in both listsType rect Field x:Int End Type Global list1:TList=CreateList() Global list2:TList=CreateList() my:rect = New rect my.x = 15 ListAddLast list1,my ListAddLast list2,my For all:rect = EachIn list1 Print all.x Next For all:rect = EachIn list2 Print all.x Next For all:rect = EachIn list1 all.x=55 Next For all:rect = EachIn list1 Print all.x Next For all:rect = EachIn list2 Print all.x Next |
| ||
Many thanks! This community rocks! |