1.请问:DELPHI中如何实现像C++中的运算符重载?
2.请问:DELPHI中如何将C++中的继承结构的类转换?如:
typedef struct tagPoint3D{
double x;
double y;
double z;
} POINT3D, *PPOINT3D;
class AFX_EXT_CLASS CPoint3D
ublic POINT3D
{
public:
CPoint3D();
CPoint3D(double ix,double iy,double iz=0.0);
CPoint3D(constdo
uble*);
CPoint3D(POINT3D p);
~CPoint3D();
public:
//operators
CPoint3D operator*(const MATRIX3D&
matrix) const;
void operator*=(const MATRIX3D&
matrix);
//offsetting with vector
CPoint3D operator+(VECTOR3D v) const;
void operator+=(VECTOR3D v);
CPoint3D operator-(VECTOR3D v) const;
void operator-=(VECTOR3D v);
BOOL operator==(POINT3D pos) const;
BOOL operator!=(POINT3D pos) const;
//derived vector = this point - sp
CVector3D operator-(POINT3D sp) const;
} ;
//operators
CPoint3D CPoint3D:
perator*(const MATRIX3D&
matrix) const
{
double rx,ry,rz,sc;
rx = x * matrix.A[0][0] + y * matrix.A[1][0] + z * matrix.A[2][0] + matrix.A[3][0];
ry = x * matrix.A[0][1] + y * matrix.A[1][1] + z * matrix.A[2][1] + matrix.A[3][1];
rz = x * matrix.A[0][2] + y * matrix.A[1][2] + z * matrix.A[2][2] + matrix.A[3][2];
sc = x * matrix.A[0][3] + y * matrix.A[1][3] + z * matrix.A[2][3] + matrix.A[3][3];
rx /= sc;
ry /= sc;
rz /= sc;
return CPoint3D(rx,ry,rz);
}
void CPoint3D:
perator*=(const MATRIX3D&
matrix)
{
(*this) = (*this)*matrix;
}
// offsetting with vector
CPoint3D CPoint3D:
perator+(VECTOR3D v) const
{
return CPoint3D(x+v.dx,y+v.dy,z+v.dz);
}
void CPoint3D:
perator+=(VECTOR3D v)
{
x+=v.dx;
y+=v.dy;
z+=v.dz;
}
CPoint3D CPoint3D:
perator-(VECTOR3D v) const
{
return CPoint3D(x-v.dx,y-v.dy,z-v.dz);
}
void CPoint3D:
perator-=(VECTOR3D v)
{
x-=v.dx;
y-=v.dy;
z-=v.dz;
}
3.请问如何在DELPHI下实现与C++相似的串行化存档?
4.请问如何在DELPHI下实现与C++相似的基于文档与视图的应用程序框架模板?