好奇为什么会失败.在返回对象而不是指针本身使用new的情况下,为什么在之后制作指针然后删除指针是非法的.我是否误解了这个序列的某些内容?
例如
Example e = *new Example(); //dereferencing the pointer to get Example object
Example* g = &e; //pointer pointing to e's address
delete g; //g is still pointer, but errors here.
Run Code Online (Sandbox Code Playgroud)