Delphi Class Declarations (__declspec)
Go Up to Classes Index
The decl-modifier argument can be delphiclass or pascalimplementation. These arguments should be used only with classes derived from Delphi classes, as follows:
- You must use __declspec(delphiclass) for any forward declaration of classes that are directly or indirectly derived from TObject.
- Use the __declspec(pascalimplementation) modifier to indicate that a class has been implemented in the Delphi language. This modifier appears in a Delphi portability header file with a .hpp extension.
Note: Another argument, delphireturn, is used internally to mark C++ classes for Delphi-compatible handling in function calls as parameters and return values.
The delphiclass argument is used to create classes that have the following compatibility:
- Delphi-compatible RTTI
- Delphi-compatible constructor/destructor behavior
- Delphi-compatible exception handling
A Delphi-compatible class has the following restrictions:
- No virtual base classes or multiple inheritance is allowed.
- Must be dynamically allocated by using the global new operator.
- Copy and assignment constructors must be explicitly defined. The compiler does not automatically provide these constructors for Delphi-derived classes.
- Must publicly inherit from another Delphi class.