Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Does anyone have trouble with this statement
Message
 
 
To
10/05/2004 14:10:17
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Miscellaneous
Thread ID:
00902540
Message ID:
00902656
Views:
16
John,

>With regard to comparing Java and C++ to VFP...
>
>Because VFP is weakly typed, it doesn’t really care about interfaces – all it cares about is applying operations to objects (in fact, Java’s interface keyword would be wasted in VFP). This means that inheritance in VFP is different from inheritance in C++ or Java, where you often inherit simply to establish a common interface. In VFP, the only reason you inherit is to inherit an implementation – to re-use the code in the base class.

In a general sense Java interfaces were created to solve the "problem" of multiple inheritance in C++. In Java the interface is defined purely as method signatures (return type and argument types). A class is allowed to implement as many interfaces as it needs without worrying about two interfaces both having the same method signature. The Java class is required to provide the implementation of every interface method.

In multiple inheritance in C++ if the two parent classes both have the same method and they both provide implementations which one does the child class inherit?

Interfaces could be quite useful in VFP (we currently have them only in the context of COM objects). I'd like to be able to define something like an iError interface and allow both my cForm and cBizObj class implement the iError interface. Right now I have to add the same method definitions to both classes instead of only having place I need to go to say what iError looks like.

In VFP it's not uncommon to define a method as "abstract" in a high level class just to get the method into the "interface" of the class, and then "require" that the subclass provide an implementation of the method. For example my low level cObject class defines a DisplayPercentComplete() method. So that every class derived from cObject can have an easy methodology to give a % complete functionality. Implementation for this method doesn't occur until a couple of levels down from cObject.
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform