|
 |
Darren New <dne### [at] san rr com> wrote:
> That's certainly part of it, but you don't need to support multiple
> inheritance in the same way C++ does it. Eiffel has multiple inheritance,
> garbage collection, and O(1) virtual dispatch. (That last would probably be
> quite difficult if you didn't compile everything at the same time, of course.)
As I have mentioned before, you can cast an object pointer to an
incompatible type assuming that:
1) Both the source and destination types have a virtual table (in C++ it's
created by making at least one member function virtual; usually at least the
destructor should be in these cases).
2) The actual object to which this pointer is pointing to has been
multiple-inherited from both the source and destination types (even if
by a very long inheritance chain).
The dynamic cast checks at runtime whether the casting is ok or not
(if it isn't, it returns a null pointer). If the object is of a type
which has been multiple-inherited from both, the dynamic cast will return
a pointer which will point to the destination type part inside the object.
Curiously, the code which performs the cast doesn't need to know that
the multiple-inherited class even exists or what it looks like, and the
cast will still work properly.
I wonder if Eiffel supports this as well.
--
- Warp
Post a reply to this message
|
 |