在 D2006中編譯DsPack2.34的時候,遇到以下代碼:TBCRefTime = object  
public
... //這裡省略了
end.function TBCRefTime.SetTime(var ll: LONGLONG): TBCRefTime;
begin
  FTime := ll;
end;想問:= object  如何理解, = class 有什麼區別。
上面的代碼如果把  = object 改成 = class , 那麼在function TBCRefTime.SetTime(var ll: LONGLONG): TBCRefTime;
這裡會有一個錯誤 :
[Pascal Error] BaseClass.pas(14756): E2064 Left side cannot be assigned to在BCB2006中編譯 = object 會報錯。

解决方案 »

  1.   

    As an alternative to class types, you can declare object types using the syntaxtype objectTypeName = object (ancestorObjectType)
      memberList
    end;where objectTypeName is any valid identifier, (ancestorObjectType) is optional, and memberList declares fields, methods, and properties. If (ancestorObjectType) is omitted, then the new type has no ancestor. Object types cannot have published members.Since object types do not descend from TObject, they provide no built-in constructors, destructors, or other methods. You can create instances of an object type using the New procedure and destroy them with the Dispose procedure, or you can simply declare variables of an object type, just as you would with records.Object types are supported for backward compatibility only. Their use is not recommended.
      

  2.   

    那么简单的E文还看不懂啊,看看FTime的定义吧
      

  3.   

    在就的object pascal中面向对象类定义是用object
    用object定义出来跟C++一样,也就是可以定义祖先类(真正没有父类的),新的一般从Tobject继承。即使Txxx=class,默认也是Tobject的子孙。
    为了兼容,保留object。
    这是我的理解,不知道是否有错误。
    我也没怎么用过object
      

  4.   

    object 是不是相當於 record 了。
    能用 record  直接替換 object 嗎? 有沒有不良影響啊。用object定义出来的類跟標准C++類一樣,可以被繼承。record 不能被繼承,除此之外有其他不同沒。object類型只為兼容舊代碼而存在,那有沒有什麼關鍵字去替換object.
      

  5.   

    record 只能有静态数据字段,而不能有过程方法函数及事件等
    object则不受这些限制
      

  6.   

    BCB和delphi定义类不一样, 默认都是从object定义,class是关键字
      

  7.   

    object是以前turbo pascal时的,也时类定义,不过没有现在的新东西,比如属性就不行
    record 肯定不是
      

  8.   

    在 D2006 中 record 可以有过程方法函数等東西的。
    D7D6中不行。也就是 這個 object 用法 沒有合適的替代品 .