Go Up to Language Support for the VCL (C++)
The Object Pascal compiler handles many of the details in working with interfaces automatically. It automatically augments the reference count on an interface when application code acquires an interface pointer and decrements that reference count when the interface goes out of scope.
In C++Builder, the DelphiInterface template class provides some of that convenience for C++ interface classes. For properties and methods in the VCL that use interface types in Object Pascal, the C++ wrappers use a DelphiInterface that is built using the underlying interface class.
The DelphiInterface constructor, copy constructor, assignment operator, and destructor all increment or decrement reference counts as needed. However, DelphiInterface is not quite as convenient as the compiler support for interfaces in Object Pascal. Other operators that provide access to the underlying interface pointer do not handle reference counting because the class can’t always tell where that is appropriate. You may need to explicitly call AddRef or Release to ensure proper reference counting.
- Delphi Interface Parameter Handled Differently Now
- Support for Object Pascal Data Types and Language Concepts