AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Logik von überladenen Operatoren ? - Grundsatzfrage
Thema durchsuchen
Ansicht
Themen-Optionen

Logik von überladenen Operatoren ? - Grundsatzfrage

Ein Thema von stoxx · begonnen am 14. Jun 2006 · letzter Beitrag vom 15. Jun 2006
Antwort Antwort
Benutzerbild von Khabarakh
Khabarakh

Registriert seit: 18. Aug 2004
Ort: Brackenheim VS08 Pro
2.876 Beiträge
 
#1

Re: Logik von überladenen Operatoren ? - Grundsatzfrage

  Alt 15. Jun 2006, 11:17
Zitat von jfheins:
Er weis ja, dass ein TIBTime (oder so) rauskommen soll, [...]
Es soll ein String rauskommen .

Ich kann das Verhalten nur für den CSC erklären, aber wenigstens würde er im oberen Beispiel das Gleiche wie der Delphi-Compiler ausspucken. Könnte also gut sein, dass die Borländer die Überladungsauflösung bei ihrem Compiler gleich oder wenigstens ähnlich gestaltet haben.
Zitat von C# Language Reference:
7.2.4 Binary operator overload resolution
An operation of the form x op y, where op is an overloadable binary operator, x is an expression of type X, and
y is an expression of type Y, is processed as follows:
• The set of candidate user-defined operators provided by X and Y for the operation operator op(x, y) is
determined. The set consists of the union of the candidate operators provided by X and the candidate
operators provided by Y, each determined using the rules of §7.2.5. If X and Y are the same type, or if X and
Y are derived from a common base type, then shared candidate operators only occur in the combined set
once.
If the set of candidate user-defined operators is not empty, then this becomes the set of candidate operators
for the operation. Otherwise, the predefined binary operator op implementations become the set of
candidate operators for the operation.
The predefined implementations of a given operator are specified in
the description of the operator (§7.7 through §7.13).
Eigene Operatoren werden also bevorzugt, der Compiler wählt die Überladung von X=TIBZeit.

Im Zweifelsfalle also lieber eine explizite Umwandlung verwenden .
Sebastian
Moderator in der EE
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:52 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