lRequestClass
is a class reference. You can call class
methods on it, but not instance methods. And FillWithTemplateData
is an instance method.
You need to have an instance to call an instance method. So instantiate one:
var
req: TReqBase;
....
req := lRequestClass.Create;
try
req.FillWithTemplateData;
...
finally
req.Free;
end;
If you develop the classes so that they need to perform work in their constructors then you must introduce a virtual constructor to TReqBase
. And override that in derived classes. That's the only way that you can make sure that the derived constructor runs when you are instantiating from a class reference.
Perhaps your system requires instances to be instantiated in some other way, I cannot tell from here. No matter what, however you instantiate then, you need an instance to call an instance method.