Fellow99 said:
Is Delphi interface The meaning is different from C and Java?
The meaning of Delphi interface is not different from C and Java, how can I not do this?
IINTERFACE1 = Interfaceend;
Iinterface2 = interface (ieterface1) procedure method (); end;
Tclass1 = Class (TinterFaceDObject, IINTERFACE2) ... End;
First, the compiler does not recognize that Tclass1 is derived by Iinterface1, must be written as a Tclass1 = Class (TinterFaceDObject, Iinterface2, Iinterface1).
Then, this is not: function xxx (): IINTERFACE2; var obj: TOBJECT; begin obj: = tclass1.create; result: = Obj as Iinterface2; // No result: = interface2 (OBJ); // No end ;
Think about it doesn't make sense,
KBS said in D7, I decided to try it in D5. The result of the test is that the first problem in D5 does not exist, the second problem, the declaration of OBJ is: VAR OBJ: Tclass1;
Yes. Because TOBJECT is not an an IINTERFACE2 because it does not inherit from interface2 in its definition. According to my opinion, the meaning of the interface is not only in grammar, but also the application: declaration, not implementation, can have a variety of different implementations. Application occasion is an ideal implementation. For example, ADO, DBEXPRESS, JDBC drivers, will have different implementations due to database categories.