朋友由Delphi语言转到C++语言后有一些不习惯,他不知道他原来用Delphi写的程序怎么能很好的转到C++,还说C++没有Delphi表达方便,没有提供Delphi这样方便的书写方式,比如:
TVector2d= record
X: Double;
Y: Double;
end;
Vector2d = TVector2d;
TPoint2d = TVector2d;
PBox2d = ^TBox2d
TBox2d = record
case Integer of
0: (StartPt, EndPt: TPoint2d);
1: (MinX, MinY, MaxX, MaxY: Double);
end;
Box2d = TBox2d;
(Delphi中是上面这样定义的,他不知道在C++中怎么定义),我一看,这种表达方式,在C++中是可以转化的呀,看来他还是转到C++时间太短了。C++代码可以写成:
typedef struct CVector2d
{
double x;
double y;
}Vector2d, Point2d;
{
struct