![]() |
Operatoren Implizit und Explizit
Hi,
kann es sein, dass die explizite Typenumwandlung nicht richtig klappt? habe:
Delphi-Quellcode:
wenn ich später dann im Code schreibe,
TBruch = record
z, n: integer; class operator Explicit(a: TBruch): string; class operator Implicit(a: TBruch): string; end; ... class operator TBruch.Explicit(a: TBruch): string; begin if a.z > a.n then result := IntToStr(a.z div a.n) + '+' + IntToStr(a.z mod a.n) + '/' + IntToStr(a.n) else result := IntToStr(a.z) + '/' + IntToStr(a.n); end; class operator TBruch.Implicit(a: TBruch): string; begin result := IntToStr(a.z) + '/' + IntToStr(a.n); end; ... dass ich ne explizite typenumwandlung will, führt er immer ne implizite durch... woran liegt das? explizit:
Delphi-Quellcode:
implizit:
s := string(b);
Delphi-Quellcode:
(s ist ein string und b ist vom typ TBruch)
s := b;
in beiden Fällen wird die Implicit funktion, oder wie auch immer man so nen Ding nennt, was nen Operator überlädt ausgeführt! *help* |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:06 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