On Sat, 26 Jun 2004 20:51:58 -0700, Jason Davidson
<[EMAIL PROTECTED]> wrote:
> 
> If you instantiate a child class, the parent class constructor is not
> called, is there a reason for this?  anyone know of plans to change
> this at all, ....
> the obvious workaround is to call the parents constructor inside the
> childs constructor, but this seems kinda strange.

I think it's unlikely to change. PHP5 also works this way, though it
uses constructor methods named "__construct" (in addition to allowing
old-style constructors with the name of the class).

<?php
// PHP5

class Foo
  {
  function __construct()
    {
    $this->x = "data";
    }
  }

class Bar extends Foo
  {
  function __construct()
    {
    parent::__construct();
    $this->y = "more data";
    }
  }
?>

FWIW Python also requires child classes to call parent constructors
manually. Not sure what the justification is for this design decision
is, though, in either language.  Anybody?

pb

-- 
paul bissex, e-scribe.com -- database-driven web development
413.585.8095
69.55.225.29
01061-0847
72°39'71"W 42°19'42"N

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to