[fpc-pascal] Virtual object methods

Ryan Joseph genericptr at gmail.com
Thu Jun 27 22:17:13 CEST 2019


Why do I get a runtime error with this?

==============================

{$mode objfpc}

program test;

// http://wiki.freepascal.org/Programming_Using_Objects
// http://wiki.freepascal.org/Programming_Using_Objects_Page_2

type
  TA = object
    procedure DoThis; virtual;
  end;

procedure TA.DoThis;
begin
  writeln('TA.DoThis');
end; 

type
  TB = object (TA)
    procedure DoThis; virtual;
  end;

procedure TB.DoThis;
begin
  writeln('TB.DoThis');
end; 

var
  obj: TB;
begin
  obj.DoThis;
end.


Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list