![]() |
![]() |
![]() |
![]() |
![]() |
|
To get the assigned value of a Vegetable instance's
instance variable, you must use a method that is known to instances of the
Vegetable class, again because only such methods have access to
instance variables. You can, for example, define a unary message,
fCalories, for instances of Vegetable:
Vegetable method definition instance fCalories ^ fCalories
Because fCalories is defined for instances of Vegetable,
fCalories is free to refer toand to answer the value ofthe
instance variable, fCalories, in a Vegetable instance.