On Saturday, Mar 29, 2003, at 07:52 US/Pacific, Raymond Camden wrote: > It is true. If in parent.cfc, outside the methods or in a method but > not > var scoped or attribute scoped, if you do x=1, then child.cfc can > access > it as well.
Let's try some real code here because I think some folks have gotten confused: parent.cfc: <cfcomponent displayname="parent"> <cfset instance = structNew()> <cfset instance.x = "Parent X"> <cffunction name="parentMethod" returntype="string"> <cfreturn this.myChild.getInstanceX()> </cffunction> </cfcomponent> child.cfc: <cfcomponent displayname="child"> <cffunction name="getInstanceX" returntype="string"> <cfdump var="#instance#"> <cfreturn instance.x> </cffunction> </cfcomponent> pc.cfm: <cfoutput> <cfset p = createObject("component","parent")> <cfset c = createObject("component","child")> <cfset p.myChild = c> <cfset instance = structNew()> <cfset instance.x = "The Calling Page X"> #p.parentMethod()# </cfoutput> Now, *if* child (composition) objects can access their parent (enclosing) objects' non-public variables, this should dump an 'instance' struct containing 'x' and print "Parent X". Which it doesn't because a child (composition) object *cannot* see any of the enclosing object's data. Run it - it says "Variable INSTANCE is undefined." inside child.cfc. Hope that clarifies? If we were talking about inheritance then, yes, the derived object has access to all of the base object's data - because CFML has only a public scope ("this") and a protected scope (unnamed). Sean A Corfield -- http://www.corfield.org/blog/ "If you're not annoying somebody, you're not really alive." -- Margaret Atwood ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Get the mailserver that powers this list at http://www.coolfusion.com Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4