Fw: Polymorphism question
| From: | Richard Fox | Date: | Fri, 15 Feb 2002 13:53:24 +0000 |
| Subject: | Fw: Polymorphism question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-84926@lists.php.net to get a copy of this message | ||
I am new to PHP but 10 years in C++
One of the cool/powerful things you can do in C++ is the following:
class DrawDialog {
public:
...
virtual Draw(); // implementation draws a plain dialog box
};
class DrawStyleDialog : public DrawPlainDialog {
public:
...
virtual Draw(); // implementation draws better dialog based on some
parameters
};
Somewhere in my code I have a function like:
void ShowGUI( DrawDialog& dd ) {
dd.Draw();
}
ShowGUI can be called with any object that is derived from DrawDialog,
obviously. Only code that calls ShowGUI must be changed when a new
implementation of DrawDialog is used. This feature of C++ to have a base
class pointer (or reference) be able to access derived class functionality
is not something I've seen in any PHP documentation. Does it exist, and if
not is there a workaround for this highly desirable feature?
TIA
Rich
PS Can anyone point me to the most comprehensive OOP documentation for PHP?
----------