This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center




7年前关闭。




这是我的作业问题



现在,我不需要该程序,但是对此问题感到困惑。我可以处理新的运算符重载,但根据要求,我应该创建一个静态成员“release()”。如果我必须追赶,该如何追回?我的意思是我应该删除什么对象。
还是我的release()原型(prototype)是错误的?

编辑:
另外,如果必须删除,可以删除5个对象中的哪一个?实际上,删除任何对象都是不正确的。我看不到任何恢复的方法。

最佳答案

听起来您需要类中的静态地址列表。每当调用new时,都将存储块的地址存储在该列表中。然后,在释放方法中,您遍历静态列表并释放内存并引发异常。

10-07 19:52
查看更多