H
H.S.
Hello,
I have class in which I am allocating space for a double array in the
constructor. I use the double array twice in one of the methods and then
delete that array in the class's destructor.
Now, that delete operation is giving me a segmentation fault. If I move
the allocation and deletion of the pointer within the method where the
pointer is being is used, it works okay ... but then another pointer
gives a segmentation fault in the destructor when that pointer is being
deleted. In all, there a bunch of pointers being used in that one
method. Memory for these is being allocated in the constructor and being
deleted in the destructor (it is not a virtual class).
I am trying to find where is the problem but haven't successful so far.
Before I continue, I have a specific question.
Am I correct in understanding that the pointer allocation using new in a
constructor of a class, then the usage of that pointer in a class member
and subsequent deletion of the pointer in the class destructor is
supposed to go okay?
Thanks.
I have class in which I am allocating space for a double array in the
constructor. I use the double array twice in one of the methods and then
delete that array in the class's destructor.
Now, that delete operation is giving me a segmentation fault. If I move
the allocation and deletion of the pointer within the method where the
pointer is being is used, it works okay ... but then another pointer
gives a segmentation fault in the destructor when that pointer is being
deleted. In all, there a bunch of pointers being used in that one
method. Memory for these is being allocated in the constructor and being
deleted in the destructor (it is not a virtual class).
I am trying to find where is the problem but haven't successful so far.
Before I continue, I have a specific question.
Am I correct in understanding that the pointer allocation using new in a
constructor of a class, then the usage of that pointer in a class member
and subsequent deletion of the pointer in the class destructor is
supposed to go okay?
Thanks.