Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
Compiler
Delphi
Language
Default Parameters
Dynamic Arrays
Overloading
Global
Method
Variants
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/Compiler/Delphi/Language/Overloading
[ Add a report in this area ]
Report #:
90333
Status:
Open
class operator in class not working
Project:
Delphi
Build #:
15.0.3953.35171
Version:
15.0
Submitted By:
Markus Ja
Report Type:
Basic functionality failure
Date Reported:
12/15/2010 6:16:01 AM
Severity:
Serious / Highly visible problem
Last Updated:
3/20/2012 3:50:14 AM
Platform:
All platforms
Internal Tracking #:
26570
Resolution:
Duplicate
Resolved in Build:
:
None
Duplicate of:
32998
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
None
Description
None
Steps to Reproduce:
the followoing line generates a compiler error:
[DCC Fehler] Unit1.pas(20): E2123 PROCEDURE, FUNCTION, PROPERTY oder VAR erwartet
TMyClass = class
class operator Implicit(a: Integer): TMyClass;
end;
----
class operator TMyClass.Implicit(a: integer): TMyClass;
begin
//result := TMyClass.Create;
end;
This is a sample of the "New Language features since Delphi 7" site
http://edn.embarcadero.com/article/34324
Workarounds
None
Attachment
None
Comments
Blaise Thorn at 12/15/2010 4:53:31 PM
-
As Designed.
Operator overloading is supported for record types only
http://docwiki.embarcadero.com/RADStudio/en/Operator_Overloading
As for http://edn.embarcadero.com/article/34324, the code snippet is probably for Delphi.NET. Nevertheless the description clearly states that "Delphi allows certain functions, or operators, to be overloaded within record declarations".
For the feature request, refer to QC#32998.
Also, please, avoid attaching .exe/.dcu files.
Markus Ja at 12/15/2010 10:31:41 PM
-
FYI: In the help file it stated that it can be used within CLASSes and RECORDs. Here are some snippets from the documentation:
- No operators other than those listed in the table may be defined on a CLASS or record.
- To access a specific operator method of a specific CLASS or record
- The compiler will use an operator for a CLASS or record provided that:
- Overloaded operators are used MOST OFTEN in records (i.e. value types).
- Operator overloads are declared within CLASSES or records, with the following syntax:
By the way. the name "class operator" is confusing, when it only works on records! Thus, it would be good to highlight in the doc that it is only valid for records.
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us