Deleting C++ pointers to an object

前端 未结 9 1184
攒了一身酷
攒了一身酷 2021-01-26 20:06

I thought that the delete command would free up memory I allocated. Can someone explain why it seems I still have the memory in use after delete?

class Test
{
pu         


        
9条回答
  •  无人及你
    2021-01-26 20:41

    I expected a seg-fault after e->time = 2;

    You shouldn't "expect" anything to happen; you are invoking undefined behavior, which by definition is, well, undefined. That means that you can no longer make any reasonable expectations about the state of your program.

提交回复
热议问题