Why doesn't deleting my pointer delete my pointer?

前端 未结 8 1736
悲哀的现实
悲哀的现实 2021-02-13 04:22

So to understand new/delete better (really to prove to myself with small examples why virtual destructors are needed for interfaces), I want to understand memory leaks, so that

8条回答
  •  半阙折子戏
    2021-02-13 05:20

    // Reserve some memory for an int and set that memory to the value 43.
    int* P1 = new int(43);
    
    // Print the address of the reserved memory.
    cout<<"P1 = "<
                                                            
提交回复
热议问题