![]() |
Default Array für Klasse
tag,
ich habe eine klasse (das unnötige hab ich weggelassen):
Delphi-Quellcode:
wenn ich nun von aussen eine instanz meiner klasse habe und darauf so zugreife:
PChannel = ^TChannel;
TChannel = class //irgendwas drinne end; TChannels = array of TChannel; TChans = class(TObject) private FChannels: TChannels; public function ChannelByName(ChannelName: string): PChannel; property Channel[idx: integer]: PChannel read GetChannel; default; end;
Delphi-Quellcode:
oder:
chans[0].someproc;
Delphi-Quellcode:
dann funktioniert das auch einwandfrei.... aber wieso geht z.b das hier nicht:
chans.channels[0].someproc;
Delphi-Quellcode:
oder das:
for i := low(chan) to high(chan) do
Delphi-Quellcode:
for i := low(chan.channels) to high(chan.channels) do
es sind doch arrays? fehler ist: "Inkompatible typen" |
Re: Default Array für Klasse
Zitat:
Wenn Du
Delphi-Quellcode:
schreibst, wird der Delphi Compiler
chans[0].someproc
Delphi-Quellcode:
daraus machen.
chans.GetChannel(0).someproc
Und
Delphi-Quellcode:
funktioniert nicht, weil, wie bereits gesagt, das Property Channel kein Array ist.
for i := low(chan.channels) to high(chan.channels) do
Delphi-Quellcode:
Ist auch nicht richtig, da Chan die Klasse selbst ist.
for i := low(chan) to high(chan) do
Du musst also eine neue Funktion oder Eigenschaft für die Anzahl der Array Elemente schreiben. :) mfG mirage228 |
Re: Default Array für Klasse
danke dann tu ich das mal *g*
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:47 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 by Thomas Breitkreuz