I think the better question is usually which compiler is better than which language is better. Especially since the language isn't squat without a good compiler that has implemented it.
This work ?Originally Posted by Almindor
You can tell me more about it ?
From brazil (:
Pascal pownz!
I don't think it would work in FPC IIRC.Originally Posted by arthurprs
This would afaik:
[pascal]
operator +(v1, v2: TVector2d) result: TVector2d;
begin
Result.x := v1.x + v2.x;
Result.y := v1.y + v2.y;
end;
[/pascal]
If you want it to compile and work in both fpc and turbodelphi then use the following:
{$IFDEF FPC}
operator +(v1, v2: TVector2d) result: TVector2d;
{$ELSE}
class operator TVector2d.add(v1, v2: TVector2d): TVector2d;
{$ENDIF}
begin
end;
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
I tried several ways to make it work,Originally Posted by JSoftware
please explain how make it with a Tpoint on Delphi
PS: i use BDS2006
From brazil (:
Pascal pownz!
Arthur, that code is for FPC. But this might be IDE independent:In the same case you can just rename it to TPoint instead if you want to.Code:{$IFDEF FPC} operator +(v1, v2: TVector2d) result: TVector2d; {$ELSE} class operator TVector2d.add(v1, v2: TVector2d): TVector2d; {$IFEND} begin Result.x := v1.x + v2.x; Result.y := v1.y + v2.y; end;
Sadly, I think we got away from your question Chris. :?
But to help directly answer what you may want to know...
Proper programming structure and practices is a key feature of the language and a mainstay of all Pascal debuggers. At least those that are made to proper standards.
C and C++ allows you to stray (sometimes too far) from the path that you should take while writing your code.
This don't compile ;/Code:unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) private public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} class operator Tpoint.add(v1, v2: Tpoint): Tpoint; begin Result.x := v1.x + v2.x; Result.y := v1.y + v2.y; end; end.
From brazil (:
Pascal pownz!
This should compileOriginally Posted by arthurprs
If you are interested in OO(the delphi way) I have written a little article(in danish) with small bits of code here:
http://udvikleren.dk/Delphi/Article.aspx/297/
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Bookmarks