|
Posted by reandeau on 08/16/06 21:38
I'm building out a OO based app in PHP 5 but I'm getting a little
confused on children contructing parents.
I have a parent that looks like this:
abstract Class State {
protected $database;
protected $user;
protected $output;
public function __construct($database,$user,$output) {
$this->database = $database;
$this->user = $user;
$this->output = $output;
}
}
And a child that looks like this:
Class Status extends State {
public function __construct($database,$user,$output) {
parent::__construct($database,$user,$output);
}
}
This seems to work OK. But I'm getting confused when thinking about
adding a new child who then has to contruct the parent again. Isn't
this getting away from the whole purpose of inheritence? It seems like
this is recreating the parent with every new child that come along.
Would it be possible to just have a single instance of the parent that
all children extended or am I missing the point here?
Thanks
Jon
Navigation:
[Reply to this message]
|