Hello,
Lets say that I have two classes, the first called Y and the second called X.
----------------------------------------------------------------------
class Y
{
public:
Y(const Y &a) //copy constructor
.
.
.
}
----------------------------------------------------------------------
#include "Y.h"
Class X
{
public:
.
.
.
private:
Y** Arr;
unsigned Arr_size;
}
----------------------------------------------------------------------
As You see, X got in private array of pointers to Y objects.
Now somewhere in the code I want to move all the objects from Arr to temp (temp is the same type as Arr, made it by using new as Arr, also temp and Arr got the same size) and delete the Arr. So I wrote this:
----------------------------------------------------------------------
for (unsigned i=0;i<Arr_size;i++)
{
temp[i]=Arr[i]; delete Arr[i];
}
delete [] Arr;
I noticed that theres a problem after the "delete Arr[i];", when I try to print temp[i] before the "delete Arr[i];" I get the exact data that were in Arr[i], however if I try to print temp[i] after the "delete Arr[i];" command I get Access Violation error.