OOP Question

From: Date: Wed, 07 Apr 2004 21:07:33 +0000
Subject: OOP Question
Groups: php.general 
Request: Send a blank email to php-general+get-182708@lists.php.net to get a copy of this message
What do members think that this code should do: class A { var $a, $b; function A($a) { $this->$a = $a; } function prnt() { echo "<br>a=" . $this->$a; } } class B extends A { function B($a, $b) { parent::A($a); $this->$b = $b; } function prnt() { parent::prnt(); echo "<br>b=" . $this->$b; } } $obj = new B("a","b"); $obj->prnt(); I think it should print a=a b=b but it seems to print (on PHP4) a= b= Cheers, Richard PS. In C++ I would be thinking of virtual functions and in Java I would be thinking of public/protected properties.

« previous php.general (#182708) next »