somFindMethod - Example Code

Assuming that the Animal class introduces the method setSound, the type name for the setSound method procedure type will be somTD_Animal_setSound, as illustrated in the Example.

#include <animal.h>
void main()
{
   Animal myAnimal;
   somId somId_setSound;
   somTD_Animal_setSound methodPtr;
   Environment *ev = somGetGlobalEnvironment();

   myAnimal = AnimalNew();
/* -----------------------------------
   Note: Next three lines are equivalent to
       _setSound(myAnimal, ev, "Roar!!!");
   ----------------------------------- */
   somId_setSound = somIdFromString("setSound");
   _somFindMethod (_somGetClass(myAnimal),
                    somId_setSound, &methodPtr);
   methodPtr(myAnimal, ev, "Roar!!!");
/* ----------------------------------- */
   _display(myAnimal, ev);
   _somFree(myAnimal);
}
/*
Program Output:
This Animal says
Roar!!!
*/


[Back: somFindMethod - Related Methods]
[Next: somFindMethod - Topics]