Thread: Listing 4-4
View Single Post
  #1 (permalink)  
Old March 26th, 2011, 08:49 AM
yfain yfain is offline
Registered User
Points: 44, Level: 1
Points: 44, Level: 1 Points: 44, Level: 1 Points: 44, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2011
Posts: 4
Thanks: 0
Thanked 1 Time in 1 Post
Default Listing 4-4

I had a couple of requests to provide more explanations regarding Listing 4-4. This was an illustration of how an instance of the class A can pass a reference to itself to an instance B. For example, There is SomeOtherClass that knows how to verify Tax and as a result can later modify some public variable(s) on the object Tax.

The object Tax passes reference to itself verifyTax(this), the instance of SomeOtherClass can do some calculations and call a method to set the results on Tax.

There is a more concrete example of passing references between the objects on page 93, where Calculator (the UI class) passes the reference to itself to CalculatorEngine - this one does the calculations and then changes the display field content on the Calculator as in Listing 9-7.
Reply With Quote