Lazarus中奇怪的对象引用

时间:2013-12-25 13:57:02

标签: class inheritance lazarus

我在Lazarus 0.9.30.2版FPC 2.4.4中遇到了一种非常奇怪和不正常的行为。如下面的代码片段所示,在对象中调用NormalizeVEctor过程后,e1和ne1变为相同的值,而我打算在e1中保留vector的原始值,ne1将表示该向量的规范化值。

var 
   e1,e2, ne1, ne2, bisector, speed,res :QVector2D;

begin 
e1 := QVector2D.Create; 
e2 := QVector2D.Create;
ne1 := QVector2D.Create; 
ne2 := QVector2D.Create;
.....
.....
ne1 := e1; 
ne2 := e2;
ne1.NormalizeVector;  ne2.NormalizeVector;// ne1 = e1 are the same values 
bisector := SubtractVector(ne2,ne1);

QVector声明如下所示

   QVector2D = class(TPersistent)
   public
    Vector :TVector3D;
    function length: Single;
    function NormalizeVector:QVEctor2D;
   end;

0 个答案:

没有答案