At 11:45 AM 11/27/2001, you wrote:
> > my answer was 160, but according to the book, the answer is 120. I thought
> > (and it says in Forta's book) that a copy of a structure is just a pointer
> > to the original so that if you change the copy, you change the
> > original. Am
> > i missing something here? Can someone explain? Thanks for any help.
>
>You're right that copies of a struct created using the assignment operator
>are simply pointers but the structCopy() function makes a deep duplicate of
>the struct that is in its own memory space and is not just a pointer to the
>original struct.
>
>So in the example from the exam the two structs are different entities

Not quite correct, if you make a structure such as

<CFSET x = structNew()>
<CFSET x.name = "Blah">
<CFSET x.y = structNew()>
<CFSET x.y.name = "Blah">

(i.e a structure with nested structures) and do

<CFSET z = structCopy(x)>

then x will be copied by value to z, but x.y will be copied by reference to 
z.y, such that....

<CFSET z.name = "Foo">
<CFSET z.y.name = "Foo">

produces the expected result...

x.name eq "Blah"
z.name eq "Foo"

but also the unexpected result...

x.y.name eq "Foo"
z.y.name eq "Foo"





----------
James Sleeman
Innovative Media Ltd
Phone: (03) 377 6262
http://www.websolutions.co.nz/

CAUTION: The information contained in this email message is confidential 
and may be legally privileged. If the reader of this message is not the 
intended recipient you are notified that any use, dissemination, 
distribution or reproduction of this message is prohibited. If you have 
received this message in error please notify the sender immediately and 
destroy the original message and any attachments.

Views expressed in this communication may not be those of Innovative Media 
Ltd.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to