SOM Kernel Reference 1-79
somDescendedFrom Method
Purpose
Tests whether one class is derived from another. Not generally overridden.
IDL Syntax
boolean somDescendedFrom (in SOMClass aClassObj);
Note: For backward compatibility, this method does not take an Environment parameter.
Description
Tests whether the receiver class is derived from a given class. For programs that use
classes as types, this method can be used to ascertain whether the type of one object is a
subtype of another.
This method considers a class object to be descended from itself.
Parameters
receiver A pointer to the class object to be tested.
aClassObj A pointer to the potential ancestor class.
Return Value
Returns 1 (true) if receiver is derived from aClassObj, and 0 (false) otherwise.
C Example
#include <dog.h>
/* ---------------------------------------------------
: Dog is a subclass of Animal.
--------------------------------------------------- */
main()
{
AnimalNewClass(0,0);
DogNewClass(0,0);
if (_somDescendedFrom (_Dog, _Animal))
somPrintf(”Dog IS descended from Animal\n”);
else
somPrintf(”Dog is NOT descended from Animal\n”);
if (_somDescendedFrom (_Animal, _Dog))
somPrintf(”Animal IS descended from Dog\n”);
else
somPrintf(”Animal is NOT descended from Dog\n”);
This program produces the following output:
Dog IS descended from Animal
Animal is NOT descended from Dog
Original Class
SOMClass
Related Information
Methods: somIsA, somIsInstanceOf
Kommentare zu diesen Handbüchern