Why can't Delphi variants hold objects?

前端 未结 3 792
再見小時候
再見小時候 2021-02-13 09:26

Why can\'t Delphi variants hold objects? More importantly, what\'s the reason behind this limitation?

3条回答
  •  长发绾君心
    2021-02-13 09:37

    You can definitely store an object inside a Variant variable - just cast it into a NativeUInt. An object is just a pointer, anyway.

    obj := TObject.Create;
    v := NativeUInt(obj);
    obj := TSomeObject(NativeUInt(v));
    

提交回复
热议问题