[fpc-devel] operator ovelroading documentation

Martin lazarus at mfriebe.de
Sun Jul 31 18:52:14 CEST 2011


On 31/07/2011 15:14, Hans-Peter Diettrich wrote:
> Martin schrieb:
>> http://www.freepascal.org/docs-html/ref/refse68.html#x164-17400012.3
>>
>> the first ( of several) examples on that page is
>>
>>> Var
>>>   C,Z : Complex; // New type complex
>
> What's "new" with that type? Where is it declared?
It's not about the type. It applies to just any type. declare your own 
"Complex" or use "TFoo"

>>>
>>> Operator := (C : Complex) z : complex;
>>
>> However, the compiler rejects that with:
>> project1.lpr(10,38) Error: Impossible to overload assignment for 
>> equal types
>
> The example doesn't declare an new type "Complex", so that most 
> probably that already existing type already *has* operators - and 
> accordingly the compiler doesn't allow to redefine these operators.
See above, same for TFoo.





More information about the fpc-devel mailing list