Re: An overloading question [message #174499 is a reply to message #174498] |
Wed, 15 June 2011 02:08 |
Jerry Stuckle
Messages: 2598 Registered: September 2010
Karma:
|
Senior Member |
|
|
On 6/14/2011 9:58 PM, sheldonlg wrote:
> On 6/14/2011 8:45 PM, Jerry Stuckle wrote:
>> Id you created it properly, then the constructor in B should be calling
>> b::y().
>>
>> I still suggest you have a mistake in your code.
>
> No, both constructors are there but are empty.
>
> Now here is the really weird thing. I decided to experiment with a
> simplified example and so copied the entire files into a test area via a
> copy/paste. I then eliminated all methods that were not called,
> eliminated all includes that were no longer needed in the classes, and
> modified the important routines to only do the printing and the one
> calling routine in the class to only call the prescribed method and not
> do any other work. So, besides the constructors (which were empty) the
> base class had two methods and the overload class had one (with the name
> as the final method invoked in the base class). The only typing I did
> was putting print statements in the final invoked methods to identify
> which one was doing the output.
>
> I expected the same result as the I had been getting. However, what
> happened was that the output was from the overloaded method, not the
> base method.
>
> Now I am totally baffled.
>
Which indicates there is some problem with your original code. It could
be anything - including misplaced /*...*/ comments, for instance.
But I looked again at your code, and I'm confused, In class A you have
public function b().
And in class B you have
public function a().
Which is it?
Also, you are aware, aren't you, that this follows the old style PHP
constructors (which are still valid) where the constructor's name is the
name of the class (instead of __construct() ).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
|
|
|