Bull DPX/20 Guida Utente Pagina 162

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 424
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 161
1-150 SOMobjects Base Toolkit: Programmers Reference Manual
somIsInstanceOf Method
Purpose
Determines whether an object is an instance of a specific class. Not generally overridden.
IDL Syntax
boolean somIsInstanceOf (in SOMClass aClass);
Note: For backward compatibility, this method does not take an Environment parameter.
Description
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))
Parameters
receiver A pointer to the object to be tested.
aClass A pointer to the class that the object should be an instance of.
Return Value
The somIsInstanceOf method returns 1 (true) if the receiving object is an instance of the
specified class, and 0 (false) otherwise.
C Example
#include <dog.h>
/* --------------------------------
: 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
*/
Vedere la pagina 161
1 2 ... 157 158 159 160 161 162 163 164 165 166 167 ... 423 424

Commenti su questo manuale

Nessun commento