Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Class Hierarchy Question
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01035408
Message ID:
01035575
Vues:
11
John,

You are not using VFP9 as you stated, are you? In VFP9 the first two class definitions you posted are illegal, in particular use of NEWOBJECT() in a property definition. It generates an error 'Statement is not valid in a class definition'.
Here's implemetation that works
DEFINE CLASS theFirst as Custom
	oSecond = Null
	myVal = Null

	PROCEDURE Init
		This.oSecond = NEWOBJECT("theSecond")
		This.myVal = this.oSecond.myVal
	ENDPROC
ENDDEFINE

DEFINE CLASS theSecond as Custom
	oThird = Null
	myVal = Null

	PROCEDURE Init
		This.oThird = NEWOBJECT("theThird")
		This.myVal = this.oThird.myVal
	ENDPROC
ENDDEFINE

DEFINE CLASS theThird as Custom
	myVal = "1234"
ENDDEFINE


>
>Thanks for the advice, but this does not work as expected. Below is a sample.
>
>"theFirst" implements "theSecond" which implements "theThird" (I know, I know, I over did it!). theThird's "myVal" property is passed up the line.
>
>
>DEFINE CLASS theFirst as Custom
>oSecond=NEWOBJECT("theSecond")
>myVal=this.oSecond.myVal
>ENDDEFINE
>
>DEFINE CLASS theSecond as Custom
>oThird=NEWOBJECT("theThird")
>myVal=this.oThird.myVal
>ENDDEFINE
>
>DEFINE CLASS theThird as Custom
>myVal="1234"
>ENDDEFINE
>
>
>So I instantiate theFirst and access members:
>
>
>oFirst=NEWOBJECT("theFirst","theClass.prg")
>? oFirst.myVal                             (prints "1234")
>? TYPE("oFirst.oSecond")                   (prints "O")
>? TYPE("oFirst.oSecond.oThird")            (prints "U")
>oSecondAndAHalf=oFirst.oSecond
>? oSecondAndAHalf.myVal                    (prints "1234")
>? TYPE("oSecondAndAHalf.oThird")           (prints "O")
>? TYPE("oSecondAndAHalf.oThird.myVal")     (prints "U")
>
>
>...you get the idea.
>
>If I try:
>
>
>? oFirst.oSecond.myVal
>
>
>I get an "Unknown member OSECOND" error.
>
>So what the hell am I missing here?
>
>Thanks!
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform