Why I can access member functions even after the object was deleted?

前端 未结 5 889
旧时难觅i
旧时难觅i 2020-11-27 23:13

I\'m new to C++ and from what I learned so far when you call delete on a pointer that points to something created on the heap then whatever is pointed by that pointer gets e

5条回答
  •  悲哀的现实
    2020-11-27 23:46

    The mechanics are that delete simply tells the system that the memory is no longer needed and can be repurposed for use again. There is no other action taken. This is the basis of the use-after-free errors seen in security disclosures. It is contingent on the programmer to not use the memory again.

    To that end, RAII is one method to attempt to reduce incidents of this problem.

提交回复
热议问题