各位帮忙看看!用Asphyre的时候碰到的问题,下面一段编译错误:
[Error] Vectors2px.pas(49): 'END' expected but 'CLASS' found
[Error] Vectors2px.pas(49): '=' expected but identifier 'Add' found
[Error] Vectors2px.pas(49): '=' expected but ',' found
[Error] Vectors2px.pas(49): '=' expected but ')' found
[Error] Vectors2px.pas(49): '(' expected but ';' found
[Error] Vectors2px.pas(50): Constant expression expected
[Error] Vectors2px.pas(49): Identifier redeclared: 'TPoint2px'
……PPoint2px = ^TPoint2px;
TPoint2px = record
x, y: Integer; class operator Add(const a, b: TPoint2px): TPoint2px;
class operator Subtract(const a, b: TPoint2px): TPoint2px;
class operator Multiply(const a, b: TPoint2px): TPoint2px;
class operator Divide(const a, b: TPoint2px): TPoint2px; class operator Negative(const v: TPoint2px): TPoint2px;
class operator Multiply(const v: TPoint2px; const k: Real): TPoint2px;
class operator Multiply(const v: TPoint2px; const k: Integer): TPoint2px;
class operator Divide(const v: TPoint2px; const k: Real): TPoint2px;
class operator Divide(const v: TPoint2px; const k: Integer): TPoint2px;
class operator Implicit(const Point: TPoint): TPoint2px;
class operator Implicit(const Point: TPoint2px): TPoint;
class operator Equal(const a, b: TPoint2px): Boolean;
class operator NotEqual(const a, b: TPoint2px): Boolean;
end;
PPoint2px = ^TPoint2px;
TPoint2px = record
x, y: Integer; class operator Add(const a, b: TPoint2px): TPoint2px;
class operator Subtract(const a, b: TPoint2px): TPoint2px;
class operator Multiply(const a, b: TPoint2px): TPoint2px;
class operator Divide(const a, b: TPoint2px): TPoint2px; class operator Negative(const v: TPoint2px): TPoint2px;
class operator Multiply(const v: TPoint2px; const k: Real): TPoint2px;
class operator Multiply(const v: TPoint2px; const k: Integer): TPoint2px;
class operator Divide(const v: TPoint2px; const k: Real): TPoint2px;
class operator Divide(const v: TPoint2px; const k: Integer): TPoint2px;
class operator Implicit(const Point: TPoint): TPoint2px;
class operator Implicit(const Point: TPoint2px): TPoint;
class operator Equal(const a, b: TPoint2px): Boolean;
class operator NotEqual(const a, b: TPoint2px): Boolean;
end;
我查了一下TPoint 的定义
Delphi syntax:type TPoint = packed record
X: Longint;
Y: Longint;
end;C++ syntax:
struct TPoint
{
TPoint() {}
TPoint(int _x, int _y) : x(_x), y(_y) {}
TPoint(POINT& pt)
{
x = pt.x;
y = pt.y;
}
operator POINT() const
{
POINT pt;
pt.x = x;
pt.y = y;
return pt;
}
int x;
int y;
};class operator Add(const a, b: TPoint2px): TPoint2px;
看你的意思是想重载'+' 运算符
还真有点高难道,希望能有高人回答这个问题!