Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dummy question about inheritance
Message
De
26/05/2006 18:55:42
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Divers
Thread ID:
01125440
Message ID:
01125444
Vues:
21
>I have the following classes:
>
>DEFINE CLASS myParent as Custom
>	myNumber = 1234
>ENDDEFINE
>
>and this one
>
>DEFINE CLASS myChild as myParent OF myparent.prg
>   *-- no action needed	
>ENDDEFINE
>
>Y and a test program
>
>*-- testInheritance.prg
>o1 = NEWOBJECT("myParent","myparent.prg")
>? o1.myNumber
>o1.myNumber = 5678
>? o1.myNumber
>o2 = NEWOBJECT("myChild","mychild.prg")
>? o2.myNumber
>
>o1 = null
>o2 = null
>
>
>Now, the question:
>Why does o2.myNumber return 1234 instead of returning 5678 ?
>
>T.I.A.

Because you're creating an instance of the disk image of the class, not the in memory instance. The value as the class is defined is 1234, the in-memory instance is 5678. You create a class instance from the defined version, not from the in-memory version.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform