Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Dummy question about inheritance
Message
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:
01125491
Views:
21
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform