Almost all of the Delphi code I have read has all the class type definitions in the units interface section, but I have seen occasional use of type definitions within the implementation section.
What exactly is the difference between these, and why would I use this?
It's pretty simple: types defined in implementation only are only visible within the implementation, so they cannot be used as types of arguments or return values in the interface. So, position your type definitions (like anything else;-) based on whether those types are only an implementation detail, or something you want to make visible externally, i.e., through the interface!
Scope. Interface declarations are public and availabe to other units when that unit is include in the Uses clause. Implementation declarations are private and only available within that specific Unit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With