Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Dummy question about inheritance
Message
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:
01125491
Vues:
23
I found an alternative solution taking some of your suggestions.
This consists in use myChild class constructor to pass as parameter the myParent object property and assign this to myChild.myNumber property.

The only issue is, the myParent object must be known
DEFINE CLASS myChild as myParent OF myparent.prg
	PROCEDURE Init(n as Integer)
		This.myNumber = n
	ENDPROC	
ENDDEFINE
and test prg
*-- testInheritance.prg
o1 = NEWOBJECT("myParent","myparent.prg")
? o1.myNumber
o1.myNumber = 5678
? o1.myNumber
*
* o2 = NEWOBJECT("myChild","mychild.prg",0,lnNumber)
* I had problems to use the parameters clause in NewObject()
*
SET PROCEDURE TO myChild.prg
o2 = CREATEOBJECT("myChild",o1.myNumber)
? o2.myNumber

o1 = null
o2 = null
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform