/*** book: "thinkinginc++" * Function: Use delete void* may error * Time: October 5, 2014 14:31:43* Author: cutter_point*/#include <iostream> Using namespace Std;class object{ void* data;//a void* type pointer const int size; const char Id;public: Object (int sz, char c): Size (SZ), ID (c) { data=new char[size]; cout<< "Create a Class" <<id<< ", size =" <<size<<endl; } destructor, output a paragraph of the execution of the destructor, and then the destructor data array ~object () {cout<< "destruction of this class" <<id<<endl; delete [] data;}; int main () { object* a=new Object (+, ' a '); Delete A; void* b=new Object (+, ' B '); Delete B; The result of the display is that B does not call the destructor //Because it does not know what type B is, then the result of the program execution is that the object memory of B is recycled, but the class content within//class is not destructor, return 0;}
"Thinkinginc++" 65, using delete void* may be an error