![]() |
AW: Abgeleitete generische Klasse ist nicht mehr generisch
Im Zusammenhang mit diesem Problem ist mir bei einem ähnlichen Konstrukt ein weiterer seltsamer Effekt aufgefallen, der sich nicht sofort erschließt:
Delphi-Quellcode:
Warum ist das denn so?
type
TGenObj<T1, T2> = class public type TGenObjRec = record A: T1; B: T2; end; TGenObjRecs = TArray<TGenObjRec>; protected procedure SetRecs(const AValue: TGenObjRecs); public property Recs: TGenObjRecs write SetRecs; end; TGenIntStrObj = TGenObj<Integer, string>; procedure TForm1.Button1Click(Sender: TObject); const RECS: array[0..1] of TGenIntStrObj.TGenObjRec = ( (A: 1; B: 'Foo'), // <-- @A: [dcc32 Fehler] E2071 Dieser Typ kann nicht initialisiert werden (A: 2; B: 'Bar') ); var LGenIntStrObj: TGenIntStrObj; begin LGenIntStrObj := TGenIntStrObj.Create; try LGenIntStrObj.Recs := RECS; finally FreeAndNil(LGenIntStrObj); end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:15 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz