The New Statement is not Allowed for Interfaces

Description

Interface identifier is specified after the New keyword when a variable is initialized.

Troubleshooting Tips

Change the code, specify an object class and an available constructor when a variable is initialized.

Example

Interface IMyInterface

End Interface IMyInterface;

Class MyClass: Object, IMyInterface

End Class MyClass;

Sub UserProc;
Var
    Obj: IMyInterface;
Begin
    Obj := New IMyInterface;
End Sub UserProc;

When the specified code is compiled, the string Obj := New IMyInterface; displays the following error: The New statement is not allowed for interfaces. To resolve the error, change the code to initialize the Obj variable. Correct code: Obj := New MyClass.Create;

See also:

Compiler Messages