help上说此类型与这个type的祖先类是assignment-compatible

解决方案 »

  1.   

    就是指向这个Class的指针。
    比如:
    TFormClass = class of TForm;var
      a: TFormClass;
      b: TForm;
    ...
      a := TForm1;
      b := a.Create(nil);
      

  2.   

    查看帮助:
    type TCollectionItemClass = class of TCollectionItem;  ...
    constructor Create(ItemClass: TCollectionItemClass);这里的Create要求你填入的值应当为类的名字,而不是一个具体的对象值
    比如可以为:
       Create(TCollectionItem)
       但是不可以为:
       var
         Item: TCollectionItem;
       begin
         ...
         Create(Item); 
       这也就是前面的定义与  
         constructor Create(Item: TCollectionItem); 
       的本质区别。
            
      

  3.   

    具体的用法,还是看看帮助比较直接。A constructor can be called using a variable of a class-reference type. This allows construction of objects whose type isn抰 known at compile time. For example,type TControlClass = class of TControl;
    function CreateControl(ControlClass: TControlClass;  const ControlName: string; X, Y, W, H: Integer): TControl;
    begin
      Result := ControlClass.Create(MainForm);
      with Result do
      begin
        Parent := MainForm;
        Name := ControlName;
        SetBounds(X, Y, W, H);
        Visible := True;
      end;
    end;The CreateControl function requires a class-reference parameter to tell it what kind of control to create. It uses this parameter to call the class抯 constructor. Because class-type identifiers denote class-reference values, a call to CreateControl can specify the identifier of the class to create an instance of. For example,CreateControl(TEdit, 'Edit1', 10, 10, 100, 20);Constructors called using class references are usually virtual. The constructor implementation activated by the call depends on the runtime type of the class reference.