On 23/12/2006, at 7:35 PM, Tom Benson wrote:
Are you sure Andy?
yes - casting never changes the actual method called but see the rest
of this message
http://www.oofile.com.au/files/REALbasic/TestRBPoly.rbp.zip
In fact I rely on this heavily in a number of my projects (being
able to call a superclasses method that I have overridden by
casting the object as it's superclass)
My bet is that you don't actually override that method in your
current class, so there's no local method to be called instead.
In that case the casting to superclass is just redundant.
Note that C++ has a special syntax which allows you to do this
ParentClass::raz() will call the ParentClass implementation of raz
from within a SubClass method.
THERE IS AN RB EQUIVALENT ALLOWING YOU TO CALL A PARENT
which I uncovered/was reminded of through writing the above example
' try calling superclass method by casting - won't work
SubClass(self).raz "CallRaz pointer to SubClass(tester).raz"
' explicitly call our superclass so it WILL work
super.raz "super.raz"
' Directly call a given method on an ancestor, not necessarily
immediate parent - this is NOT casting
ParentClass.raz "ParentClass.raz"
For very very good reasons, you can't change which method is called
from OUTSIDE the class but you can choose to use a parent
implementation INSIDE the class.
regards
Andy
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>