unit Unit1;interfaceuses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs;type
  tBase = class(TPersistent)
  public
    procedure virFunc; virtual;
    procedure SomeFunc;
  end;
  PTBase = ^TBase;  tTest = class(tBase)
  public
   procedure virFunc; override;
   procedure SomeFunc;
  end;
  PTtest = ^TTest;  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    list1: TList;
    list2: TList;    procedure funcA;
    procedure funcB;
  end;var
  Form1: TForm1;implementation{$R *.dfm}procedure tBase.virFunc;
begin
  ShowMessage('base_virFunc');
end;procedure tTest.virFunc;
begin
  ShowMessage('test_virFunc');
end;procedure TForm1.funcA;
var
  t     : TTest;
  test  : TTest;
  pTest : PTBase;
begin
  //往list及list1中分别加入一个对象和对象的指针
  t := TTest.Create;
  list1.Add(t);
  list2.Add(@t);  //分别取出对象及对象的指针,并调用对象的方法SomeFunc
  test  := TTest(list1.items[0]);
  pTest := PTBase(list2.items[0]);
  test.SomeFunc;
  pTest.SomeFunc;end;procedure TForm1.funcB;
var
  test  : TTest;
  pTest : PTBase;
begin
  //分别取出对象及对象的指针,并调用对象的方法SomeFunc
  test  := TTest(list1.items[0]);
  pTest := PTBase(list2.items[0]);
  test.SomeFunc;
  pTest.SomeFunc; //出错
end;procedure TForm1.FormCreate(Sender: TObject);
begin
  list1 := TList.Create;
  List2 := TList.Create;
  funcA;
  funcB;
end;procedure TForm1.FormDestroy(Sender: TObject);
begin
  List1.Free;
  List2.Free;
end;{ tTest }procedure tBase.SomeFunc;
begin
  ShowMessage('base');
end;procedure tTest.SomeFunc;
begin
  ShowMessage('test');
end;end.
上面的程序,如果把TBase中的SomeFunc改为虚函数就会出错, 为什么?