At 13:05 01.12.2002, Bernard Chamberland said:

[...omitting long code post...]


couple of things:
a) Class "Ressource" uses instance data ("$this->") in the constructor. You
shouldn't call this as a static method (see derived class "Plant").

b) Class "Plant": use the commented-out method in the constructor to access
the ressource's instance data. You should get an error otherwise ($this is
not defined for Ressource::Ressource).

c) Now to your original question: your problem is the class constructor for
"Rain" which receives a COPY of $jungle, not a HANDLE (PHP-speak: not a
REFERENCE) to the jungle object. You should code your Rain constructor like
    function Rain(&$jungle) {
        $this->jungle = $jungle);

This should give you the correct results as far as I can see. If you miss
out passing a REFERENCE instead of a VARIABLE (which would be a COPY of the
jungle object), rain falls in the copied jungle, and your original jungle
remains dry.

Hope this gets you started. As a rule of thumb, always pass REFERENCES when
you're dealing with object handles.

   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to