SOM GetClass

This macro returns the class object of which a SOM object is an instance.

Syntax
 SOMObject   objPtr; SOMClass    rc;

rc = SOM_GetClass(objPtr); 

Parameters

 * objPtr (SOMObject) : A pointer to the object whose class is needed.

Return Code
rc (SOMClass)

Remarks
The SOM_GetClass macro returns the class object of which obj is an instance. This is done without recourse to a method call on the object. The somGetClass method introduced by SOMObject is also intended to return the class of which an object is an instance, and the default implementation provided for this method by SOMObject uses the macro.

Important Note: It is generally recommended that the somGetClass method call be used, since it cannot be known whether the class of an object wishes to provide special handling when its address is requested from an instance. But, there are (rare) situations where a method call cannot be made, and this macro can then be used. If you are unsure as to whether to use the method or the macro, you should use the method.

Example Code
 main {  Animal *a = new Animal; SOMClass cls1 = SOM_GetClass(a); SOMClass cls2 = a->somGetClass; if (cls1 == cls2) printf("macro and method for getClass the same for Animal\n"); else printf("macro and method for getClass not same for Animal\n"); } 
 * 1) include 
 * 2) include 

Methods

 * somGetClass