Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Child class in code does not contain method from parent
Message
De
17/06/2004 13:26:34
 
 
À
16/06/2004 21:52:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00914483
Message ID:
00914690
Vues:
10
>>>I created three classes in code, as a three level hierarchy, paren, child and grandchild. In the parent class I placed some methods which, for the time being, are not mentioned in the child and grandchild classes.
>>>
>>>After instanciating an object based on the grandchild class, I was surprised to find that the methods defined in the parent class but not in the child class do not show up, as would happen if the classes were created visually.
>>>
>>>Am I doing something wrong, or must all methods be mentioned in each level?
>>>
>>>Note: The methods that were mentioned in the intermediate class and not in the grandchild class did show up in the object. I am using VFP8.
>>>
>>>TIA,
>>>
>>>Alex
>>
>>Seems to work for me:
>>
>>ox = NEWOBJECT("childclass","levels.prg")
>>ox.childmeth()
>>ox.parentmeth()
>>ox.grandparentmeth()
>>
>>
>>
>>*levels.prg
>>DEFINE CLASS childclass AS parentclass
>>FUNCTION childmeth
>>WAIT WINDOW "Child"
>>ENDFUNC
>>ENDDEFINE
>>
>>DEFINE CLASS parentclass AS grandparentclass
>>FUNCTION parentmeth
>>WAIT WINDOW "Parent"
>>ENDFUNC
>>ENDDEFINE
>>
>>DEFINE CLASS grandparentclass AS custom
>>FUNCTION grandparentmeth
>>WAIT WINDOW "GrandParent"
>>ENDFUNC
>>ENDDEFINE
>>
>
>Hi Fred,
>
>I don't think it would mke any difference if I called them procedures instead of functions, right? In my case each class is in separate prg file, too: that may be more important. I've placed each class in a different prg and all prgs are in SET PROCEDURE files. What do you think? Thanks.
>
>Alex

As long as all the classes can find each other that they're derived from it all should work. You did do SET PROCEDURE ... ADDITIVE, correct? FUNCTION/PROCEDURE should make no difference.
Fred
Microsoft Visual FoxPro MVP

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

Click here to load this message in the networking platform