TSonClass = class(TFatherClass)
....
end;...
C: TFatherClass;
C := TSonClass.Create;

解决方案 »

  1.   

    TParent = Class( TObject )
    Public
          GetCount; Virtual;
    End;TChild = Class( TParent )
    Public
          GetCount; Overirde;
    End;Var
       X : TParent;X := TChild.Create;
    X.GetCount;
    ....
      

  2.   

    这是父类:
    type
      TfBasePopedom = class(TForm)
        procedure FormCreate(Sender: TObject);
      Protected
        procedure AddItemToTreeView(); virtual;
      end;procedure TfBasePopedom.FormCreate(Sender: TObject);
    begin
      AddItemToTreeView;
    end;procedure TfStationPopedom.AddItemToListView();
    beginend;这是子类:
    type
      TfStationPopedom = class(TfBasePopedom)
      Protected
        procedure AddItemToTreeView(); virtual;
      end;procedure TfStationPopedom.AddItemToTreeView();
    begin
      ShowMessage('测试');
    end;
      

  3.   

    Delphi中的虚函数模型和C++中的一样是通过vtable实现的啊,你用父类的实例去引用子类的实例时,此时调用的虚函数就是此子类啊,如果你直接用父类的实例调用此函数,他就调用就是父类的。