1. The difference between creating a new class object and creating a new class Object
Ii. Create a new class object instance 1. Create a new Class Object example:
CTest * pTest = new CTest ();
Delete pTest;
PTest is used to receive class object pointers.
Use the Class Definition Statement directly without using new:
CTest mTest;
This method does not need to be manually released after use. This type of destructor is automatically executed. The new application object will only execute the Destructor when the delete operation is called. If the program exits and the delete operation is not executed, memory leakage will occur.
2. Define only class pointers
This is very different from declaring objects without new statements. Class pointers can be defined first, but class pointers are only common pointers. Before new, they are allocated with any memory space. For example:
CTest * pTest = NULL;
.
Note: