SomIsInstanceOf

This method determines whether an object is an instance of a specific class. Not generally overridden.

For backward compatibility, this method does not take an Environment parameter.


 * Original Class : SOMObject

Syntax
boolean somIsInstanceOf (SOMObject receiver, SOMClass aClass)

Parameters

 * receiver (SOMObject) : A pointer to the object to be tested.


 * aClass (SOMClass) : A pointer to the class that the object should be an instance of.

Return Code

 * rc (boolean) : Returns 1 (true) if the receiving object is an instance of the specified class, and 0 (false) otherwise.

Remarks
Use the somIsInstanceOf method to determine if an object is an instance of a specific class. This method tests an object for inclusion in one specific class. It is equivalent to the expression:

(aClass == somGetClass (receiver))

Example Code
 /* --  Note:  Dog is derived from Animal. -- */ main { Animal myAnimal; Dog myDog; SOMClass animalClass; SOMClass dogClass;
 * 1) include 

myAnimal = AnimalNew ; myDog = DogNew ; animalClass = _somGetClass (myAnimal); dogClass = _somGetClass (myDog); if (_somIsInstanceOf (myDog, animalClass)) somPrintf ("myDog is an instance of Animal\n"); if (_somIsInstanceOf (myDog, dogClass)) somPrintf ("myDog is an instance of Dog\n"); if (_somIsInstanceOf (myAnimal, animalClass)) somPrintf ("myAnimal is an instance of Animal\n"); if (_somIsInstanceOf (myAnimal, dogClass)) somPrintf ("myAnimal is an instance of Dog\n"); _somFree (myAnimal); _somFree (myDog); } /* Output from this program: myDog is an instance of Dog myAnimal is an instance of Animal 

Methods

 * somDescendedFrom
 * somIsA