No viable overloaded =

Hi, I have what seems to be quite a weird problem in my code (I can discuss the issue and answer questions but cannot post big chunks of my code due to code sharing rules on this class project)

I have a class called Particle which represents particles in 3d space. One of its' private attributes is its' velocity.
This velocity is of type Vector (Vector being a class defined in another part of the program with many useful methods such as dot product etc), and has size 3.
I have written a public function in the Particle class which is called as follows from the main when a collision is detected between (say) particle1 and particle2 to calculate the new velocity vectors.


Everything is working well, I have gone through the debugging process to inspect variables and the results obtained by the bounce function are all correct.

However, at the end of the function when I try to put a result into the velocity attribute for particle2 by doing
particle2.velocity = someObjectOfTypeVector
and I get
No viable overloaded '='

This is weird because the line before puts a result into the velocity attribute for particle one I wrote
velocity = someObjectOfTypeVectorand this works fine, even with the debugger I can see that the velocity attribute of particle1 has been correctly updated.

This is really annoying because I need to move onto the last leg of the project which is implementing OpenGL and can't find a solution elsewhere on the internet so any help would be much appreciated :)
Last edited on
Just out of curiosity, what's the prototype for the Particle::bounce function?

Can you also post the exact error message in its entirety?
Last edited on
Is particle2 passed as a const reference by any chance?
Oh my god thank you so much I can't believe I missed that for such a long time!
Indeed the prototype was
void Particle::bounce(const Particule &particle2);
Thanks so much!! :) removed the const and all works beautifully!
Topic archived. No new replies allowed.