![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
In Chapter 11, you learned that each instance of a class contains its
own set of instance-variable values, so each Food
instance, for
example, contains its own values for the fCalories
,
cCalories
, and pCalories'
variables.
Because each instance maintains its own values for all instance variables, you would not want to use an instance variable for a value that does not vary from one instance to another.
For example, the number of calories contributed to a food by a gram of fat does not vary from food to food.