到了这里,你也许会说,说了半天,都是猜测,或许,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