![]() |
pointer to an array in D und C++
Moin!
Ich habe versucht, diese funktion in deplhi zu übersetzen. Alles klappt in die Zeile BinImgPlus[idx]=0; Kann man pointer auf array in Delphi so nicht deklarieren? Ich möchte aber in Delphi die array-Struktur beibehalten. Geht das? Vielen Dank!
Delphi-Quellcode:
int BinImgMatchProMile( const bool* BinImg1, const bool* BinImg2, int nElements, bool* BinImgPlus, bool* BinImgMinus) { //local declares register idx, MatchCounter=0; //calculations for (idx=0; idx<nElements; ++idx){ //local initialisation BinImgPlus[idx]=0; BinImgMinus[idx]=0; //Find out what to do for this element if (BinImg1[idx]==BinImg2[idx]) //Got a match in case BinImg1 == BinImg2 MatchCounter++; else if (BinImg1[idx] && (!BinImg2[idx])) //Got positive difference in case BinImg1 > BinImg2 BinImgPlus[idx]=1; else if (BinImg2[idx] && (!BinImg1[idx])) //Got negatice difference in case BinImg1 < BinImg2 BinImgMinus[idx]=1; //endif } return (int)(((float)MatchCounter/(float)nElements)*1000.0); } |
Re: pointer to an array in D und C++
Sorry Ich meinte - alles klappt BIS in die Zeie! :oops:
|
Re: pointer to an array in D und C++
Scheisse!
Könnte mir vielleicht doch einen kleinen Tipp geben? Ich bitte nicht darum, die Funktion umzuschreiben, blos wie macht man das in D mit pointer auf array? |
Re: pointer to an array in D und C++
So ein Mist, alta. Ick wer gleich verrückt! Son Schheissforum! :wall:
|
Re: pointer to an array in D und C++
Moin moin
Also, ganz sicher bin ich mir da jetzt auch nicht aber versuch doch mal Folgendes:
Delphi-Quellcode:
oder hab ich dich da verstanden-Miss :wink:
.
. . type myArray = array[0..10] of String; var aArray : myArray; myPointer : ^myArray; . . . begin aArray[1] := 'Hallo Welt'; myPointer := @aArray; showmessage(myPointer^[1]); end; . . . schönen Gruß Sam |
Re: pointer to an array in D und C++
Danke Dir!
Ichh glaube, du verstandest michh schon richtig. In C wird als übergabeparameter bool* BinImgPlus, bool* BinImgMinus deklariert und dann, wie du siehst, als arrays verwendet. Delphi lässt das leider nicht. Und deine Lösung mag schon richtig sein, man hat mir sonst auch geraten, Einen Array-Typ zu definieren. .. |
Re: pointer to an array in D und C++
Geht nicht. Naja, egal , ich probiere mal weiter.
|
Re: pointer to an array in D und C++
Zitat:
Roderich |
Re: pointer to an array in D und C++
Zitat:
Delphi-Quellcode:
type
PBooleanArray = ^TBooleanArray; TBooleanArray = array [0..High(Integer) - 1] of Boolean; function BinImgMatchProMile(const BinImg1, BinImg2: TBooleanArray; nElements: Integer; out BinImgPlus, BinImgMinus: TBooleanArray): Integer; cdecl; var idx: Integer; MatchCounter: Integer; begin Result := 0; if (nElements > 0) then begin MatchCounter := 0; // calculations for idx := 0 to nElements - 1 do begin // local initialisation BinImgPlus[idx] := False; BinImgMinus[idx] := False; // Find out what to do for this element if BinImg1[idx] = BinImg2[idx] then // Got a match in case BinImg1 = BinImg2 Inc(MatchCounter) else if BinImg1[idx] and not BinImg2[idx] then // Got positive difference in case BinImg1 > BinImg2 BinImgPlus[idx] := True else if BinImg2[idx] and not BinImg1[idx] then // Got negatice difference in case BinImg1 < BinImg2 BinImgMinus[idx] := True; end; Result := Int64(MatchCounter) * 1000 div nElements; end; end; |
Re: pointer to an array in D und C++
@nicoDE,
wenn ich es gekonnt hätte, hätte ich unwissend gelassen. @virchow beiße nie den Herrn der dich füttert. raik |
Alle Zeitangaben in WEZ +1. Es ist jetzt 07:57 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