Prev | Current Page 208 | Next

Carl Reynolds and Paul Tymann

"Schaum's Outline of Principles of Computer Science"

If a subordinant class does not
override the method of the superior class, instances of the subordinant class will respond to the method just as
instances of the superior class do. If my Ford ???is??? a FamilyCar, my Ford also ???is??? an Automobile, because
FamilyCar inherits from Automobile.
INSTANCE AND STATIC VARIABLES AND METHODS
One twist of complexity is that some state information and some behaviors belong to the class, while others
belong to the instances of a class. For instance, we would maintain the speed of each Automobile as part of
the state of each individual car (part of the state of each instance). On the other hand, we would maintain a
count of the total number of Automobiles as part of the state of the class Automobile. It seems natural
that speed should be associated with a particular car, but we need a central place to keep track of the total
number of Automobiles.
Perhaps we??™re stretching the analogy a little bit, but imagine a Ford on the road. It has a speed we can
measure, but after the Ford exits the factory, there is no easy way for the Ford to be kept apprised of the total
number of Automobiles that have been built. If we want to know how many Automobiles have been
built, we must go back to the factory and get the count.


Pages:
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220
traktorki ogrodowe need cash fast bad credit prace wysokościowe Program TV projekty domków letniskowych