NB:
The Vecteur class is included in the particle class, a particle has three private attributes, its' position and speed (which are of type Vecteur) and its' mass (a double)
The output() method simply outputs the contents of the system class (eg The system has n particles, prints out the contents of each particle as there exists an overloaded << operator in the Particle class that prints out the type of particle (He,Ne...), position, speed, masss)
1 2 3 4 5 6 7 8 9 10
|
int main()
{
Helium part1(Vecteur(1,2,3), Vecteur(4,5,6), 8);
Neon part2(Vecteur(1,5,3), Vecteur(3,4,5),2);
System system;
system.addParticle(part1);
system.addParticle(part2);
system.output();
return 0;
}
|
The output is fine with this code, the output() function even prints out what it's supposed to by iterating through the unique_ptrs in the vector and prints out the right types etc there is just a memory problem going on somewhere.
The code used to add a particle is the same as written in "The code I am trying is as follows (implemented in the System.cpp file)" in my post May 12, 2014 at 11:19am.
Once again sorry about not being able to post big chunks of code :/
By selectively commenting out lines, putting in breakpoints I have confirmed beyond a doubt that issue really lies with the addParticle method.