Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Does vfp support polymorphism?
Message
 
À
20/06/2003 19:21:54
Gerry Schmitz
GHS Automation Inc.
Calgary, Alberta, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Divers
Thread ID:
00802118
Message ID:
00802981
Vues:
29
>IMO, polymorphism becomes particularly useful when passing objects to general routines and you want to perform an operation on that object and do not know (or care) what kind of an object it is ... you just want to operate on it in a consistent manner (ie. using a common method name) and have it respond appropriately.
>

Yes, this is the essense of polymorphism. You cast the specialized instance to the more general instance and program against the interface of the general type. Polymorphism will make sure that the specialized behavior gets executed.

You do care what type it is. It must be a superclass of the specialized type (or implement an interface) otherwise you will get a runtime error in vfp (or a compile time error in a strongly typed language).
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform