有没有任何编译器选项让编译器给我一个错误,而不是一个警告,当我实例化一个抽象类?
- Foo = class
- procedure Bar; virtual; abstract;
- end;
- var
- f : Foo;
- begin
- f := Foo.Create; // <-- should give me a compile time error
- end;
解决方法
在Delphi 2010中(至少可能是早期的版本,但不能测试/验证):
- Project -> Options
- + Delphi Compiler
- > Hints and Warnings
- + Output Warnings:
- Constructing instance containing abstract method: ___________
将此设置从“True”更改为“Error”