これに似た質問がありますが、デルファイです。
type
TThreadPopulator = class(TThread)
private
_owner:TASyncPopulator; //Undeclared identifier
end;
type
TAsyncPopulator = class
private
_updater: TThreadPopulator;
end;
上記の質問の解決策は、デルファイには適用されません
これに似た質問がありますが、デルファイです。
type
TThreadPopulator = class(TThread)
private
_owner:TASyncPopulator; //Undeclared identifier
end;
type
TAsyncPopulator = class
private
_updater: TThreadPopulator;
end;
上記の質問の解決策は、デルファイには適用されません
Forward Declarations and Mutually Dependent Classes
ドキュメントを参照してください。
type (* start type section - one unified section "to rule them all" *)
TAsyncPopulator = class; (* forward declaration, it basically serves just to
fix SizeOf(TAsyncPopulator) so compiler would be able to draft dependent types'
in-memory layout. Down the CPU level `class` and `pointer` is the same, so now
Delphi knows SizeOf(TAsyncPopulator) = SizeOf(pointer) to compose further types *)
TThreadPopulator = class(TThread)
private
_owner:TASyncPopulator;
end;
TAsyncPopulator = class (* the final declaration now, it should go WITHIN
that very TYPE-section where the forward declaration was made! *)
private
_updater: TThreadPopulator;
end;
....
type
(* now, that you had BOTH forward and final declarations for TAsyncPopulator
spelled out above, you finally may start another TYPE-section, if you choose so.
But only after them both, and never should a new `type` section be inserted
in between those declarations. *)
....
ソースを使え、ルーク!Delphi インストールには、読み、見て、学ぶための完全な VCL および RTL ソースがあります。そして、このテンプレートをよく使用します。「どうすればそれができるのか」と自問するたびに、「Borland はどのようにそれを行ったのか」を考えるだけで、Delphi が提供するソースで既製の例をすでに入手できる可能性が高くなります。
クラス定義の前にこれを使用します。フォワード クラスは Delphi 2010 で動作します。お持ちのデルファイのウィッチ バージョンはわかりませんが、考えられる唯一の解決策です。
type
TAsyncPopulator = Class;
私が助けてくれることを願っています
前方宣言を使用する以外に、サブクラスを作成してこれを解決することもできます。
TThreadPopulator = class(TThread)
type
TAsyncPopulator = class
_updater: TThreadPopulator;
end;
var
owner: TAsyncPopulator;
end;