|
Posted by Schraalhans Keukenmeester on 05/25/07 07:05
At Thu, 24 May 2007 23:07:18 -0700, Ryan van Roode let his monkeys type:
> Hello,
>
> An API function gives me an object of class 'Blah'. I have subclassed
> 'Blah' and added a few methods:
>
> class EnhancedBlah extends Blah {
> function enhancement1() {}
> function enhancement2() {}
> }
>
> Is there a way to 'downcast' the object to a subclass? Something like
> this:
>
> $blah = SuperApi::getBlah();
> $enhancedBlah = (EnhancedBlah) $blah;
>
> Thanks for your help.
>
> ~RvR
Nope. Simple reason: Every cat (ExtendedBlah) is a mammal (Blah), not
every mammal (Blah) a cat (ExtendedBlah).
So you can treat Enhancedblah as a Blah, but not the other way around.
HTH
Sh.
Navigation:
[Reply to this message]
|