new and delete, p150

Creating an object, without () is called without providing an explicit initialization, () is a value called null initialization.

No built-in types and types defined default ctor, without () uninitialized with () to zero. But there is a default constructor, with or without () are initialized with the default constructor.

 

Overhanging pointer (dangling pointers): delete p actually release the pointer points to memory, that memory is not what the pointer is not deleted. This action will make the pointer becomes a pointer overhang. Point to an object once stored memory.

Once you delete an object pointer points immediately pointer is set to 0. This indicates that the pointer will not point to any object.


const object must be initialized when you create

Delete const objects
Although you can not change the value of a const object, but you can delete the object itself, such as delete pci.

Guess you like

Origin www.cnblogs.com/Stephen-Qin/p/11620041.html