operator overloading question

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

operator overloading question

Alexey Pavluchenko
Hello all,

When trying to compile the following code

=== cut===
unit foo;

interface

  type tbar = record
    somefield: integer;
  end;
       pbar = ^tbar;

  operator + (a: pbar; b: pbar) c: pbar;

implementation

  operator + (a: pbar; b: pbar) c: pbar;
  begin
  end;

end.
=== cut===

the compiler (2.0.4) stops with the "impossible operator overload"
message. Two questions arise: 1) why is it considered impossible and
2) how can I workaround this?

--
Best regards,
 Alexey


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: operator overloading question

Bugzilla from daniel.mantione@freepascal.org


Op Tue, 8 May 2007, schreef Alexey Pavluchenko:

> the compiler (2.0.4) stops with the "impossible operator overload"
> message. Two questions arise: 1) why is it considered impossible

Overloading pointers turned out to be too problematic in the past, so it
was to be disabled. Overloading dynamically allocated data structures is
problematic anyway due to memory management.

> and
> 2) how can I workaround this?

You can overload Tbar instead.

Daniƫl
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal