You are here: Child construct parent « PHP Programming Language « IT news, forums, messages
Child construct parent

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация