I have a std::vector
which contains some objects. How can I use memory addresses (do I want to use the this
pointer for this purpose?) to check whether I am doing something with the same object?
For example:
void particle::calcFrc(std::vector<particle>& particles)
{
vector3d tRel;
mFrc.reset();
for(unsigned int j = 0; j < particles.size(); j ++){
if(... what goes here? ...){
tRel = particles.at(j).mPos - mPos;
if(tRel != zero()){
// do stuff
}
}
}
}
I want to do a check in the if
statement to see whether particles.at(j)
is referring to the same object from which this method was called.