Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BUG: HIDDEN a property is unusable
Message
De
23/02/2005 12:39:35
 
 
À
22/02/2005 16:54:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9
Divers
Thread ID:
00987841
Message ID:
00989711
Vues:
37
>>The question is: does an inherited method execute in the context of the SubClass or of the SuperClass ?
>
>>I'm tempted to say that it is the former and that there should be no error on the second call() of the example
>
>Well, the example of Fabio shows, that the inherited procedure is running in the context of the Superclass. But the property is (re)defined in the context of the Subclass, so it's quite right, that the SuperClass code execution fails, because the overridden property is hidden in the context of SuperClass, because the property belongs to the SubClass.
>
>I've tried to overcome that by also overriding the call procedure (but not overloading it with the same code, that would break inheritance):
>
>DEFINE CLASS subClass  as SuperClass
>   hiddenproperty = 2
>   HIDDEN hiddenproperty
>
>   PROCEDURE call
>      SuperClass::call
>   ENDPROC
>ENDDEFINE
>
>
>But that doesn´t change the context of the call procedure. There seems no way out, but I think that's by design and I wonder if some other language handles this differently.
>
>Bye, Olaf.


Well, Olaf, I guess this is open to interpretation.

I'm just saying that (1) the subclass does not define a new property, it only hides an existing, and (2) if the Call() method is inherited, why would it not execute at the same level ? The property is still in the class definition of the subclass, even in the definition of the superclass

See, SuperClass did not know the property would need to be hidden at the time it was designed, otherwise it would have hidden it or made it protected.

It's only when Subclass came along and had a different view of its situation (the subclass world), that it decided to hide an existing property

And I think that hiding a property defined in the parent class is equal to defining a new property ..... by design ;-)
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform