somDescendedFrom
Appearance
This method tests whether one class is derived from another. Not generally overridden.
For backward compatibility, this method does not take an Environment parameter.
- Original Class
- SOMClass
Syntax
boolean somDescendedFrom (SOMClass receiver, SOMClass aClassObj)
Parameters
- receiver (SOMClass)
- A pointer to the class object to be tested.
- aClassObj (SOMClass)
- A pointer to the potential ancestor class.
Return Code
- rc (boolean)
- Returns 1 (true) if receiver is derived from aClassObj.
- Returns 0 (false) if receiver is not derived from aClassObj.
Remarks
This method 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.
Example Code
#include <dog.h>
/* --------------------------------------------
Note: 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
Related
- Methods