Original Post
hi every one. ok I am getting nuts, because the destructor is called twice, witch make me get an assertion error: BLOCK_HEAD_IS_VALID, any here is the example: class TEST { public: int* ptr ; TEST() ; ~TEST() ; }; TEST::TEST() { ptr = new int[10] ; } TEST::~TEST() { cout << "calling destructor..." << endl ; if (ptr) {delete ptr ; ptr = NULL; }; } TEST Function() { TEST result ; return result ; } void main() { Function() ; } the output of this example is like this: calling destructor... calling destructor... so the destructor was called twice, wich makes me get an assertion error, because I am deleting a null array (just like this: int* ptr = new int[10]; delete ptr; delete ptr;). any way, does any one know what is happening here, caus I am getting really confused here. and what shout I do to evercome this probleme?