Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Hidden property exposed as public
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Titre:
Hidden property exposed as public
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Divers
Thread ID:
01479474
Message ID:
01479474
Vues:
120
- Using VFP SP2 (.6303) -
It appears that property defined as hidden in the superclass, will be exposed as public by an instance of a subclass, if the same property is assigned a value in the superclass.init, and the subclass.init invokes a DODEFAULT()
Is this normal?
*
Here is the sample code (run it in a prg):
LOCAL oX, iAx
LOCAL ARRAY laM[1]
*
oX = CREATEOBJECT("xTestSub")
*
ACTIVATE SCREEN
*
? "--- Property h1 defined as Hidden in the superclass, however --- "
IF AMEMBERS(laM, m.oX, 0, "G#") > 0
   iAx = ASCAN(laM, "H1", 1, -1, 1, 14)
   IF m.iAx > 0 AND "G" $ laM[m.iAx, 2]
      ? "Subclass instance has property h1 exposed as public" FONT "Courier New", 10
   ENDIF
ENDIF
* m.oX.h1 access should fail
? "Should not be able to access h1", m.oX.h1 FONT "Courier New", 10 STYLE "BI"
m.oX.h1 = "new value to h1"
* m.oX.h1 assign should fail
? "Furthermore, should not be able to assign", m.ox.h1 FONT "Courier New", 10 STYLE "BI"
*
?
	
*=====================================
DEFINE CLASS xTestSub AS xTestBase
*=====================================

	*************************
	FUNCTION Init
	*************************
	DODEFAULT()   && this seems to make it happen
	RETURN .T.
	
	
ENDDEFINE


*=====================================
DEFINE CLASS xTestBase AS Custom
*=====================================
	
	HIDDEN h1
	h1 = ""
	
	*************************
	FUNCTION Init
	*************************
	This.h1 = "value from superclass.init"
	RETURN .T.

ENDDEFINE
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform