testdefaultparams.out

来自「格式化源码的最新板」· OUT 代码 · 共 78 行

OUT
78
字号
unit testdefaultparams;

interface

function def1(const pival: integer = 42): boolean;
function def2(bv: boolean = False; const pival: integer = 42): boolean;
function def3(bv: boolean = False; const piaverrylongvalval: integer = 42;
  const short: integer = 42): boolean;

type
  thasdefs = class(TObject)
  public
    procedure fred(const pi: integer = 3; px: double = 34.4); virtual;
    procedure jim(const pi: integer = 3; px: double = 34.4); overload;
    procedure jim(pb: boolean = False); overload;
    procedure bob(const pi: integer = 3; px: double = 34.4); overload;
    procedure bob(const pblongvariablename: pointer = nil;
      const pi: integer = 3; px: double = 34.4); overload;
  end;

implementation

procedure thasdefs.bob(const pi: integer; px: double);
begin
  if pi > 3 then
  begin
    px := pi;
  end;
end;

procedure thasdefs.bob(const pblongvariablename: pointer; const pi: integer; px: double);
begin
end;

procedure thasdefs.fred(const pi: integer = 3; px: double = 34.4);
begin
  if pi > 3 then
  begin
    px := pi;
  end;
end;

function def1(const pival: integer = 42): boolean;
begin
  Result := (pival = 42);
end;

function def2(bv: boolean = False; const pival: integer = 42): boolean;
begin
  if bv then
    Result := def1(pival)
  else
  begin
    Result := def1;
  end;
end;

function def3(bv: boolean = False; const piaverrylongvalval: integer = 42; const short: integer = 42): boolean;
begin
  def2(bv);
end;

procedure thasdefs.jim(const pi: integer; px: double);
begin
  if pi > 3 then
  begin
    px := pi;
  end;
end;

procedure thasdefs.jim(pb: boolean);
begin
  if pb then
    jim(pb);
end;

end.
 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?