⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nestedclass.pas

📁 source code for Marco Cantu s book Delphi 2007 Handbook
💻 PAS
字号:
unit NestedClass;

interface

type
  TOne = class
  private
    someData: Integer;
  public
    // nested constant
    const foo = 12;
    // nested type
    type TInside = class
      type TInsideInside = class
        procedure Two;
      end;
    public
      procedure InsideHello;
    private
      Msg: string;
      InsIns: TInsideInside;
    end;
  public
    procedure Hello;
    constructor Create;
  end;

implementation

uses
  SysUtils;

{ TOne }

constructor TOne.Create;
begin
  inherited Create;
end;

procedure TOne.Hello;
var
  ins: TInside;
begin
  ins := TInside.Create;
  try
    ins.Msg := 'hi';
    ins.InsideHello;
    writeln ('constant is ' + IntToStr (foo));
  finally
    ins.Free;
  end;
end;

{ TOne.TInside }

procedure TOne.TInside.InsideHello;
begin
   someData := 22;
   writeln ('internal call');
   if not Assigned (InsIns) then
     InsIns := TInsideInside.Create;
   InsIns.Two;
end;

{ TOne.TInside.TInsideInside }

procedure TOne.TInside.TInsideInside.Two;
begin
  someData := 22;
  writeln ('this is a method of a nested/nested class');
end;

end.

⌨️ 快捷键说明

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