在 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 會報錯。
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 會報錯。
解决方案 »
- 高人进来帮我下,看看这段代码到底哪里错误,这个循环第一次循环可以,第二次不行!
- 如何使用ActiveX对当前IE的打印参数进行设置,哪位大侠帮帮忙啊,跪谢了。。。
- MessageBox提示信息没有显示在最前面
- 怎样通过某个对象的句柄去获取它的内存地址?
- 各位大侠,快来帮帮忙了!!毕业设计急需解决的问题,请一定援手
- 关于打开文件,如何指定程序打开指定文件
- 怎么的到今天是今年中的第多少个星期?急
- DBgrideh控件用过的人请进来一下
- CSDN学习史(第五问)
- activeform中加入button按钮 发布后在属性窗口中能改变button的属性
- 使用Fastreport替换报表中的值的问题!
- (在线)delphi怎么控制Excel的单元格文字自动换行
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.
用object定义出来跟C++一样,也就是可以定义祖先类(真正没有父类的),新的一般从Tobject继承。即使Txxx=class,默认也是Tobject的子孙。
为了兼容,保留object。
这是我的理解,不知道是否有错误。
我也没怎么用过object
能用 record 直接替換 object 嗎? 有沒有不良影響啊。用object定义出来的類跟標准C++類一樣,可以被繼承。record 不能被繼承,除此之外有其他不同沒。object類型只為兼容舊代碼而存在,那有沒有什麼關鍵字去替換object.
object则不受这些限制
record 肯定不是
D7D6中不行。也就是 這個 object 用法 沒有合適的替代品 .