对Object Pascal编译器给类对象分配堆内存细节的一种大胆猜测(下)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 mahongxi 的 blog

到了这里,你也许会说,说了半天,都是猜测,或许,op编译器根本就不会调用那个tobject.newinstance方法呢!

问得好,再做实验!

还是以上面的那个tbase类为例,重载tobject.newinstance方法,如下:

tbase = class(tobject)

    x : integer;

    y : double;

    class function newinstance: tobject; override;

    procedure freeinstance; override;

    constructor create;

  end;

 

{实现}

constructor tbase.create;

begin

本文关键:Object Pascal 分配内存
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top