Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Proper way of coding a class
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Title:
Proper way of coding a class
Miscellaneous
Thread ID:
00592667
Message ID:
00592667
Views:
58
I have the following sample class/method structure. There is a problem with it and I am trying to find the best way to code it.

Define Test as custom
function showString(aString)
? aString
endfunc
Enddefine

Define Test1 as Test
function fixFunc(aString)
this.showString('String: '+aString)
endfunc
Enddefine

Define Test2 as Test1
function showString(aString)
this.fixFunc(aString)
endfunc
Enddefine

The problem is when I use showString() in Test2. It calls fixFunc() which then should call my showString() in Test. instead, of course, it calls the one in Test2 and goes into infinite recursion. I can use Test::showString() instead of this.showString() and it would work. But then that means you have to specify the class of any method you are using which defeats a main feature of inheritance.

My question is: How can i make a showString() in Test2 without messing with the code in Test and Test1.

Thanks
Next
Reply
Map
View

Click here to load this message in the networking platform