In my code I have a struct named bead. and I have a vector which is defined as
vector< vector< vector <vector <bead*> > > > boxes
Sometimes, I need to make some changes to the boxes and I might need to revert those changes.
What happen if I do the following:
vector< vector <vector <vector <bead*> > > > nBoxes;
nBoxes = boxes;
....
//some code that resizes the forth nest in nBoxes and create new content
....
boxes = nBoxes;
Will the data in boxes be changed through changes applied to nBoxes?
here is the definition of bead:
struct bead{
particle mainPart;
int charge;
int type;
double rho;
double nextRho;
int LID;
double U;
double nextU;
bool touch;
};
which requires the definition of particle
struct particle{
vec pos;
vec oldPos;
vec vel;
vec oldVel;
vec F;
vec oldF;
};
vec is a class that hold a velarray parameters along with bunch of functions to manipulate it.
I think that you meant
boxes = nBoxes;
in the end.
operator = of vector copies the contents of the vector. That is, in your case it copies the pointers to bead. The bead objects themselves aren't deep-copied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With