somIsInstanceOf - Example Code
#include <dog.h>
/* ----------------------------------
Note: Dog is derived from Animal.
---------------------------------- */
main()
{
Animal myAnimal;
Dog myDog;
SOMClass animalClass;
SOMClass dogClass;
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
*/
[Back: somIsInstanceOf - Related Methods]
[Next: somIsInstanceOf - Topics]