Re: Inheritance of class methods

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Using extends means that a class IS-A substructure of its parent class(es).

EXAMPLE:

class plant { };
class tree extends plant { };
class apple_tree extends tree { };

apple_tree inherits all methods and attributes from plant and tree
So if there was a methods plant->growth() you can also call it from
tree and apple_tree

IS-A versus HAS-A

apple_tree IS-A tree
apple_tree HAS-A fruit called apple

So apple does not extend apple_tree because it is not a tree

EXAMPLE:

class apple {
var color = 'blue';
var inhabitant = 'worm';
}
class apple_tree extends tree {
var apples = array(new apple());
}

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux