Re: [PHP4BETA] calling member in parent class
| From: | Thierry-Michel Barral | Date: | Mon, 07 Feb 2000 08:34:11 +0000 |
| Subject: | Re: [PHP4BETA] calling member in parent class | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-9899@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Peter Kovacs" <php4-peter@knowpost.com>
To: <chagenbu@wso.williams.edu>
Cc: <php4beta@lists.php.net>
Sent: Sunday, February 06, 2000 2:29 AM
Subject: Re: [PHP4BETA] calling member in parent class
Peter
<<
Since you already have to change the name of the class that your
extending, it's only a matter of a search&replace on *that file*.
Example:
Foo.php:
class Foo { ... }
Bar.php:
class Bar extends Foo { ... Foo::afun() ... }
Now, when Foo changes to Foop, you *have* to change "class Bar extends
Foo" to "class Bar extends Foop" anyway, so what's the big deal about
searching and replacing in the entire file?
>>
But let's see another example:
We have a class root named Control, 2 subclasses, Button and Edit.
The class Button have 2 subclasses, Checkbox and Radio.
I have an object of class Control.
And depending of the choice of the user, I want to create a Button, a Checkbox, ...
<pseude code>
obj: Control
switch (theObjTheUserWant)
button:
obj= new Button
checkbox:
obj= new Checkbox
...
If I need to have the width of my obj, I can call Control::width().
But if the width of Control is nul, and the width of a button is always 150 pixels, when I will have
a checkbox, calling
Control::width() is not right because I will obtain a nul width instead of the width of 150 pixels
for the buttons.
So, here, calling parent->width() is the right way.
kktos