对象的多态1 Objects example - Polymorphism 1
提示:虚拟和重写的方法
提示:调用
核心源码
// Class can pass it’s functionality to descedant class 类可以将其功能传递给子类
type
TMyClass = class
Field1: string;
LastName: string;
function GetBothFields: string; virtual;
// virtual means that can be overriden 虚拟意味着可以被覆盖
end;
TMySecondClass = class(TMyClass)
Address: string;
function GetBothFields: string; override;
// override means it will provide it’s own implementation and not the inherited method
//重写意味着它将提供自己的实现,而不是继承的
end;
implementation
{ TMyCla