Q:

Function of a class returning an array that is declared after the class

I somehow haven't dealt with this problem before. I have a class 
  TRoom = class
   private
     width, length, X1,X2,Y1,Y2, index: integer;
   public
     function draw: RoomArr;      
     procedure setparam;
     function getparam: integer;
  end;

Now, below that, because Delphi 7 can't return Arrays of TClass, I have declared this:
RoomArr = Array of TRoom;

This somehow fixes the problem. No idea why, I just found this solution on the internet
I am using the "RoomArr" in other functions and it works fine, as expected. 
But as the array is declared after the class (otherwise it would not know the class TRoom), TRoom itself (more precisely the function "draw") cannot use it. 
Is there any way to bypass this problem?
Thanks in advance.

A:

You need a forward declaration:
type
  TRoom = class; // forward declaration

  TRoomArr = array of TRoom; // so that array type can be declared before class

  TRoom = class
    function Draw: TRoomArr; // and used by class
  end;

A:

A forward declaration of TRoom:
Type
  TRoom = class; // forward declaration

  RoomArr = Array of TRoom;

  TRoom = class
    ...
    function draw: RoomArr;
  end;

The forward declaration must be completed in the same type section.

