I am a Java developer who has recently been pulled into the Delphi developer hat.
As is usually the case in such situations, I end up trying to do something in Delphi, still use the “Java” mindset, and I get embarrassed when they don't work.
Today, the problem is the concept of an interface. In Java, I can define an interface, give it several methods, and then declare a class that implements this interface.
I tried to do the same in Delphi, and my fingers were burned. I announced an interface that extended IInterface. But when it came time to implement this interface, I was met by a number of unfulfilled methods errors for methods that I did not declare (QueryInterface, _AddRef, _Release).
Little Google told me that I need to extend TInterfacedObject instead of TObject. This caused me concern because it suggests that I cannot just add an interface to a third-party class if this class does not extend TInterfacedObject.
But now that it's time to set up my paired object. Free, I get EInvalidPointer exceptions.
As a result, I begin to conclude that the word interface means something completely different than the Java developer and the Delphi developer.
Can someone who speaks both languages educate me about the differences?
Greetings.
source
share