Delphi调用爷爷类的方法

Delphi通过inherited 可以调用父类的方法,但是没有提供直接调用父类的父类的方法(爷爷类),通过变通的方式实现如下:

假设父类是TFather,爷爷类TGrand,调用爷爷类的Write方法:

type
  TWriteProc=procedure of Object;
var
  WriteProc:TWriteProc;

....
  TMethod(WriteProc).Code:=@TGrand.Write;
  TMethod(WriteProc).Data:=Self;
  WriteProc;

  

原文地址:https://www.cnblogs.com/hezihang/p/4139656.html