9.5. Inheriting the ConstructorWas there anything specific to Horse in that method? No. Therefore, it's also the same recipe for building anything else inherited from Animal, so let's put it there:
Ahh, but what happens if you invoke speak on an instance?
You get a debugging value: a Horse=SCALAR(0xaca42ac) goes neigh! Why? Because the Animal::speak routine expects a classname as its first parameter, not an instance. When the instance is passed in, you'll use a blessed scalar reference as a string, which shows up as you saw it just now—similar to a stringified reference, but with the class name in front.
Copyright © 2003 O'Reilly & Associates. All rights reserved. |
|