Re: [Lazarus] operator overloading

2013-02-24 Thread xrfang
nks. 在 日, 2月 24, 2013 at 4:21 下午,leledumbo 写道: FPC operator overloading doesn't work inside classes, it must be declared globally, so method2 should work. What error do you get? What FPC version do you use? -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/L

Re: [Lazarus] operator overloading

2013-02-24 Thread Sven Barth
On 24.02.2013 16:02, xrfang wrote: I will test again tomorrow to find out what's wrong with my code. For now, one more queston: I noticed that generics does not work without {$mode objfpc}. I wonder what is the default mode without $mode? Why objfpc is not the default mode? The default mode

Re: [Lazarus] operator overloading

2013-02-24 Thread Wildfire
> Both variants will work. The variant with "b: Boolean" was originally > introduced for the non-Object-Pascal modes (fpc, tp), because there you > only have the name of the procedure/function as a result variable and as > operators don't have names (in that sense) you can specify the name of >

Re: [Lazarus] operator overloading

2013-02-24 Thread Sven Barth
On 24.02.2013 08:31, xrfang wrote: Hi All, How can I use operator overloading? I know the syntax, but it simply does not compile... My situation is: 1. I wrote a TTreap generic class, which is a binary tree. 2. TTreap defines a Compare() with involves < and > operation on its keys. 3. I try t

Re: [Lazarus] operator overloading

2013-02-24 Thread xrfang
道: On 24.02.2013 15:51, Wildfire wrote: > *From:* xrfang > *Sent:* Sunday, February 24, 2013 7:31 AM > *To:* Lazarus@lists.lazarus.freepascal.org > > *Subject:* [Lazarus] operator overloading > > operator < (p1, p2: TPainter) b: Boolean; <—method2 > Close, bu

Re: [Lazarus] operator overloading

2013-02-24 Thread Sven Barth
On 24.02.2013 15:51, Wildfire wrote: *From:* xrfang <mailto:xrf...@gmail.com> *Sent:* Sunday, February 24, 2013 7:31 AM *To:* Lazarus@lists.lazarus.freepascal.org <mailto:Lazarus@lists.lazarus.freepascal.org> *Subject:* [Lazarus] operator overloading > operator < (p1, p2: TP

Re: [Lazarus] operator overloading

2013-02-24 Thread Wildfire
From: xrfang Sent: Sunday, February 24, 2013 7:31 AM To: Lazarus@lists.lazarus.freepascal.org Subject: [Lazarus] operator overloading > operator < (p1, p2: TPainter) b: Boolean; <—method2 Close, but no cigar... operator < (p1, p2: TPaint

Re: [Lazarus] operator overloading

2013-02-24 Thread leledumbo
FPC operator overloading doesn't work inside classes, it must be declared globally, so method2 should work. What error do you get? What FPC version do you use? -- View this message in context: http://free-pascal-lazarus.989080.n3.nabble.com/Lazarus-operator-overloading-tp4029399p4029400

[Lazarus] operator overloading

2013-02-23 Thread xrfang
Hi All, How can I use operator overloading?  I know the syntax, but it simply does not compile...  My situation is: 1. I wrote a TTreap generic class, which is a binary tree. 2. TTreap defines a Compare() with involves < and > operation on its keys. 3. I try to specialize it with the following:

Re: [Lazarus] operator overloading

2010-10-22 Thread Felipe Monteiro de Carvalho
overload the := operator instead. Search for the free pascal docs on operator overloading. -- Felipe Monteiro de Carvalho -- ___ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Re: [Lazarus] operator overloading

2010-10-22 Thread Vincent Snijders
2010/10/22 Birger Jansen : > Hi, > > In Delphi you can overload the Explicit operator. This makes is possible to > have a type TTypeX and TTypeY and cast one into the other. To do that, > implement an operator overloader: >  operator Explicit(const AValue: TTypeX): TTypeY. >  // implement convers

[Lazarus] operator overloading

2010-10-22 Thread Birger Jansen
Hi, In Delphi you can overload the Explicit operator. This makes is possible to have a type TTypeX and TTypeY and cast one into the other. To do that, implement an operator overloader: operator Explicit(const AValue: TTypeX): TTypeY. // implement converstio from TTypeX to TTypeY. Then you c