Orchid XP v3 <voi### [at] devnull> wrote:
> OK, well how would you build (say) a linked list structure if the new
> node goes out of scope as soon as you get to the end of the function
> that creates it and adds it to the list?
It goes out of scope, but it has two references pointing to it
(one in the function and another in the list data structure). When
it goes out of scope in the function that simply decreases the
reference count by one.
> OK, how about a double-linked list?
> Every node (except the end ones) always has 2 other nodes pointing to
> it. Hence the reference count will never reach zero. QED.
The nodes at the ends of the list have only one.
--
- Warp
Post a reply to this message
|