testgenericconstructorstatic.out

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

OUT
46
字号
program TestGenericConstructeurStatic;

{$APPTYPE CONSOLE}

{ AFS December 2007 

  This code compiles, but is not semantically meaningfull.
  It is test cases for the code-formating utility

  Test new generics syntax - code from TridenT
}

uses
  SysUtils;

type
  EContrainteArgumentException = class(ArgumentException);

  MaClasse<T> = class
    UnChamp: T;
    S: string;
    constructor Create;
    class constructor CreateClass;
  end;

  constructor MaClasse<T>.Create;
  begin
    inherited;
    S := 'Initialisation';
    Writeln(#9 + #9 + #9 + 'Appel du constructeur d''instance', Self.ClassName, '.Create');
  end;

  class constructor MaClasse<T>.CreateClass;
  var
    UnEntier:   integer;
    VarGeneric: T;
  begin
    Writeln;
    Writeln(#9 + #9 + 'Appel du constructeur de classe MaClasse.CreateClass<', Typeof(T), '>');
    VarGeneric := default(T);
    UnEntier   := 10;

    //Est-ce un type valeur et le param閠re de type est-il un integer ?
    if (assigned(TObject(VarGeneric)) = True) and (TObject(UnEntier) is T) then
      raise EContrainteArgumentException.Create(
        'L''utilisation du type Integer n''est pas autoris

⌨️ 快捷键说明

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