Separating Interface and Implementation classes in delphi?
class, delphi
Solution
My first advice: Skip this $Include thing altogether. As Uwe wrote find a more Delphi-like solution.
If you really want to stay with the $Include style: The error you quote occurs because forward declarations don't work across "type" blocks. You forward declare TScheduleList in one block but define it in a different block. To cure this omit the "type" keyword in your *Intf.pas's and insert it in BusinessDomain.pas before the includes.
Problem
Am separating my delphi code into interface and implementation units ie. EmployeeIntf.pas looks like this ``` type // forward declaration TScheduleList = class; TDeparment = class; TEmployee = class(BDObject) .... function GetSchedules: TScheduleList; function GetDepartment: TDepartment; end; TEmployeeList = class(DBList) .... end; TEmployeeDM = class(BDDBobject) ... end; ``` Then i have the two units ScheduleIntf.pas & DepartmentIntf.pas which declare the TScheduleList class and TDepartment class. Then in my main unit which combines all the units looks like this, ``` Unit BusinessDomain Interface uses classes {$I Interface\EmployeeIntf.pas} {$I Interface\DepartmentIntf.pas} {$I Interface\ScheduleIntf.pas} Implementation uses SysUtils {$I Implementation\EmployeeImpl.pas} {$I Implementation\DepartmentImpl.pas} {$I Implementation\ScheduleImpl.pas} Initialization finalization end. ``` When i compile this the compiler throws an error; ``` *Type TScheduleList is not yet completely defined* ``` How can i have this classes separate in each unit file (.pas) and then do forward declarations without the compiler throwing this error? The class themselvs are huge and i would prefer to separate them this way.