局部变量不像全局变量可赋初始值, 但可以通过编译指令把指定类型的常量当作变量用, 如:

const
{$J+}
  num: Integer = 1;
{$J-}
begin
  Inc(num);
  ShowMessage(IntToStr(num)); {2}
end;

//或者写作:
const
{$WRITEABLECONST ON}
  num: Integer = 1;
{$WRITEABLECONST OFF}
begin
  Inc(num);
  ShowMessage(IntToStr(num)); {2}
end;


这没有使用价值, 了解而已.

相关文章:

  • 2021-06-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-05
  • 2021-08-10
  • 2021-09-20
  • 2022-02-15
相关资源
相似解决方案