0

I am not an expert in C++, but this is really freaking me out ... I am working on a 3D matrix (>>), and writing overcharged operators to manipule it using push_back.

when I add stuff on the first and second 'dimensions', it works fine For instance:

Construction& Construction::operator-=(const Construction& c) .....

... contenu[level].push_back(c.contenu[level][depth]); ... no problem!

But when I create another operator+= to manipulate the last dimension, hell breaks loose

Construction& Construction::operator+=(const Construction& c) ...

... contenu[level][depth].push_back(c.contenu[level][depth][width]);

For some unexplainable reason, now, push_back modifies its parameter c.contenu !!!??? It's not supposed to do that, and even less on a const& parameter.

And since that instruction is in a loop that runs until it reaches the end of c.contenu, it actually never does and never stops.

It is really that line that causes problems because I have checked c.contenu right before and after the instruction, and somehow it changes.

I peeled my eyes, both instructions are similar, I actually copied the first one and modified it, and there's no typo or anything fundamentally different.

Any idea?

PS: this is my first post here, so sorry if I was not clear enough, but I'd appreciate the help.

JPB
  • 11
  • 2

0 Answers0