That is a copy constructor
for objects of class type Vector3D. One case where you would implicitly call a copy constructor is when you pass an existing instance by value as argument to a function. My guess is that is happening in the calls to AddToVector
and SetPosition
and SetVelocity
, as I indicated in the comments below, a total of 5 calls. You might be curious why the copy constructor
is not called when you invoke SetVelocity(Vector3D()), that is best explained, if you care to know, by reading the explanation here:
Correct usage of rvalue references as parameters
const Vector3D& CurrentR_NMinus1 = Particles[i].GetPosition();
const Vector3D& CurrentR_N = Particles1[i].GetPosition();
const Vector3D& CurrentA_N = CalculateAcceleration(Particles1,i);
// Calculate R_N+1
Vector3D CurrentR_NPlus1;
CurrentR_NPlus1.AddToVector(CurrentR_N); // copy constructor called
CurrentR_NPlus1.LinearCombine(2, CurrentR_NMinus1, -1);
CurrentR_NPlus1.LinearCombine(1, CurrentA_N, pow(StepSize,2));
// Calculate V_N
Vector3D CurrentV_N;
CurrentV_N.AddToVector(CurrentR_NPlus1); // copy constructor called
CurrentV_N.LinearCombine(1,CurrentR_NMinus1,-1);
CurrentV_N.ScalarMultVector(1/(2*StepSize));
// Update
Particles[i].SetPosition(CurrentR_N); // copy constructor called
Particles[i].SetVelocity(CurrentV_N); // copy constructor called
t0 += StepSize;
Particles1[i].SetPosition(CurrentR_NPlus1); // copy constructor called
Particles1[i].SetVelocity(Vector3D());
t1 += StepSize;