Hi again.
I've written a small unit to work with 3D vectors. It compiles
without errors, but when I'm trying to use the operators I defined
from a program I get the "invalid operands to binary" error.
But I can use the type defined in the unit without problems. The
source code is the following:
***************************
Unit vectores;
Interface
{$X+}
{$W-}
Type
TVector = Record
x, y, z: Real;
End;
Operator + ( a, b: TVector ) c : TVector;
Operator - ( a, b : TVector ) c : TVector;
Operator * ( a, b : TVector ) c : Real;
Operator / ( a : TVector; b : Real ) c : TVector;
Operator * ( a : TVector; b : Real) c : TVector;
Operator * ( a : Real; b : TVector) c : TVector;
Function modu ( a : TVector ) : real;
Implementation
Operator + ( a, b: TVector ) c : TVector;
Begin
c.x := a.x + b.x;
c.y := a.y + b.y;
c.z := a.z + b.z;
End;
Operator - ( a, b : TVector ) c : TVector;
Begin
c.x := a.x - b.x;
c.y := a.y - b.y;
c.z := a.z - b.z;
End;
Operator * ( a, b : TVector ) c : Real;
Begin
c := (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
End;
Operator / ( a : TVector; b : Real ) c : TVector;
Begin
c.x:=a.x / b;
c.y:=a.y / b;
c.z:=a.z / b;
End;
Operator * ( a : TVector; b : Real) c : TVector;
Begin
c.x:=a.x*b;
c.y:=a.y*b;
c.z:=a.z*b;
End;
Operator * ( a : Real; b : TVector) c : TVector;
Begin
c.x:=a*b.x;
c.y:=a*b.y;
c.z:=a*b.z;
End;
Function modu ( a : TVector ) : real;
Begin
modu := sqrt(sqr(a.x)+sqr(a.y)+sqr(a.z));
End;
{$W+}
End.
***************************
Does anybody know what's wrong?
Thank you, Ariel
---
Ariel Bendersky
bender(a)einstein.com.ar