Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dummy question about inheritance
Message
From
26/05/2006 18:55:42
 
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01125440
Message ID:
01125444
Views:
19
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform