且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

为什么在Delphi中类不能使用运算符重载?

更新时间:2023-11-14 13:27:52

关闭。这是因为对象是引用类型,并且内存是手动管理的。所以如果你说 myResult:= myObject1 + myObject2 + myObject3; ,你必须在那里创建一个中间对象,没有代码释放它,所以你获得内存泄漏。

Close. It's because objects are reference types and the memory is managed manually. So if you said myResult := myObject1 + myObject2 + myObject3;, you'd have to create an intermediate object somewhere in there, and there's no code to free it, so you get memory leaks.