Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Testing if an object is an instance of a class
Message
De
07/10/2005 05:05:15
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Testing if an object is an instance of a class
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
01057071
Message ID:
01057071
Vues:
50
Hello,

When testing parameters given to a function, I was wondering if there was a simple way to test whether an object x is an instance of a custom class A when inheritance is involved.
For example, class A inherits from Custom, class B inherits from class A, class C inherits from class B and I want to test object x so that it would answer indifferently yes whether the Class property of x is A, B or C. Unfortunately with the ParentClass property I can recurse only up one level.
Said otherwise, I would need is to construct is a function InstanceOf(oObject,cClassName), returning .T. if and only if the class of oObject is cClassName or one of its subclasses.

Thank you for your help,

David
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform