posted 18 years ago
Think of the reference type as a remote control (this is explained better in some of the tutorials on the Ranch). I can have a remote control to a basic XYZ brand tv. it has a power button, volume up and down, and channel up and down buttons. it will work with ANY XYZ brand TV.
but then my piture tube blows, so i get a second hand, fancier XYZ tv, with built in surround sound functionality. I can still use my basic remote. when i push the 'power' button, the fancy XYZ tv will turn itself on. The remote just says "hey - turn on" and the TV uses it's own logic to figure out how to do that.
but i can't use my basic remote to control the surround sound features - they're simply not on my remote, so i can't press those buttons. the TV could DO all that stuff, i just don't have any way to TELL it to do them - unless i get a new remote that's the right kind.
in your last example, i have two base references. using those references, i can only call the funtions known to the base class. but when you call a method with the base_ref_sub_object_class reference, since the ACTUAL OBJECT is a sub_class, you'll get the method defined in the sub_class.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors