I have a class TRow = class(TInterfaceList) where the items I want to add are descendants from IField (TFieldType1 and TFieldType2)
I have a method where I want to iterate through the items and call an IField method on them:
(Item[i] as IField).IFieldMethod
And I am getting Abstract Error?
What am I doing wrong? Am I wrong in my OOP understanding or Delphi?
Thank you
You’ve got a class implementing
IField.IFieldMethodusing aabstract virtualmethod, and you ignored aConstructing instance of <TType> containing abstract method <MethodName>.Here’s a short console demo of code that exhibits your error. The fact that you’re calling
IFieldMethodusing(Item[i] as IField).IFieldMethoddoesn’t provide any new information, it only hides the cause of the problem. Store theIFieldtype interface reference to a local variable and you’ve got my code: