Hello,

my comments are below this snippet.

------------------------------------------------------------
class AGENT{
/*
** 2003-09-04 jb PRIVATE PROPERTIES */
var $strCommCode; // agent commission code
------------------------------------------------------------


------------------------------------------------------------
function AGENT(){       // class pseudo-constructor
                /*
                ** 2003-09-09 jb initialize properties
                */
                $this->strCommCode = 'COINBASE';
------------------------------------------------------------

------------------------------------------------------------
require("agentclass.php");

class COIN extends AGENT {
        var $strCommCode = 'COIN0JAY';
}

/*
** instantiate new COIN object
*/

$objDime = new COIN();
echo $objDime->strCommCode."\n"; ------------------------------------------------------------


The result of $objDime->strCommCode is 'COINBASE'...my thinking is that
it should be 'COIN0JAY'


You can get the expected result if you add an empty constructor to your Coin class.

ASAIK php does not believe in the concept of default constructors. If a class does not have a constructor it will happily call the constructor in the super class instead and leave it at that. While on the other hand if you have a constructor in your subclass the constructor in the superclass does not get called!. I don't like it either but that's the way it's 'defined to be' in PHP.

To sum up your strCommCode in the COIN class does override the strCommCode member in AGENT. But it's value is actually set by the constructor in AGENT and it's not the value that you define at the time of declaration.

best regards

--
http://www.radinks.com/upload
Drag and Drop File Uploader.

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



Reply via email to