[DGD] Auto and Driver objects

Felix A. Croes felix at dworkin.nl
Sun May 25 12:47:42 CEST 2003


"Ben Chambers" <bjchamb at bellsouth.net> wrote:

>[...]
> Then to make a specific backpack or something I would want to inherit both
> the base object and the container object, but with the container object's
> versions of move from and move into overriding the versions defined in the
> base object.  Would this be possible?  Basically, the base version provides
> the default 'You can't move that from that to that' behavior, while the
> container provides the you can move it, and the end object is the specific
> version of how this is done.

By inheriting from two different objects that both define the same
function, you introduce a conflict.  That conflict must be resolved by
masking the function in the inheriting object, like this:

    inherit base "/foo/bar/base";
    inherit container "/foo/bar/container";

    int MoveInto(object item)
    {
	return container::MoveInto(item);
    }

    int MoveFrom(object item)
    {
	return container::MoveFrom(item);
    }

There are other ways in which this issue can be addressed.  For instance,
the container object could be made to inherit the base object, in which
case its functions would automatically override those of the base object.
Should another object then inherit both, the compiler will understand
that the container functions are meant to mask those of the base object,
and no conflict will ensue.

Regards,
Dworkin
_________________________________________________________________
List config page:  http://list.imaginary.com/mailman/listinfo/dgd



More information about the DGD mailing list