Re: Re: Polymorphism in PHP

From: Date: Mon, 18 Feb 2002 20:46:01 +0000
Subject: Re: Re: Polymorphism in PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85278@lists.php.net to get a copy of this message
On Mon, 2002-02-18 at 12:12, Richard Fox wrote: > That's right, the difference between C++ "pure virtual" and "virtual" > is > that a virtual function has an implementation but pure virtual only defines > an interface. > > But can we get back to my original PHP question: Can I do something like the > following in php: What happened when you tried it? I got 'BaseDerived1Derived2' on 4.2.0. Torben > class Base { > function Foo() { echo "Base"; } > } > > class Derived1 extends Base { > function Foo() { echo "Derived1"; } > } > > class Derived2 extends Base { > function Foo() { echo "Derived2"; } > } > > function Example ( $objvar ) { > $objvar->Foo(); > } > > ... > > $obj1 = new Base(); > $obj2 = new Derived1(); > $obj3 = new Derived2(); > Example($obj1); > Example($obj2); > Example($obj3); > > I think what I am asking is, is there any concept of a virtual function in > PHP, with a virtual function table? > > Rich > > > -----Original Message----- > From: Martin Towell [mailto:martin.towell@world.net] > Sent: Sunday, February 17, 2002 5:31 PM > To: php-general@lists.php.net > Subject: RE: [PHP] Polymorphism question > > > A bit late in replying - but what the hay (or is that "hey"??) oh well... > > >From my understanding of virtual functions (and it's been at least 3 to 4 > years since I've done C++) is that a "virtual function" has basic > functionality and a "pure virtual function" has no, and can't have, and > code. > > Please correct me if I'm wrong > > Martin > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- Torben Wilson <torben@php.net> http://www.thebuttlesschaps.com http://www.hybrid17.com http://www.inflatableeye.com +1.604.709.0506

« previous php.general (#85278) next »