Persoanlly I wouldnt do what you are doing.
Containers of pointers are tricky as the destructors dont get called when the container goes out of scope.....there are other horrors as well so where possible try to avoid them (Scott Meyers says in his books to only try use pointers if you are using smart pointers...and those you will have to design yourself)....
Another nasty is that calling push_back in a loop without reserving memory for the object is not usually the most efficeint way....and there's no need as you are using the default constructor for your Particle!!
Add to this that if new throws an exception in say the 5th object created in the constructor, your destructor will not be called and you will leak the 4 objects previously created!
Personally, I would initialise my vector to be created with a certain number of objects constructed from a default constructor for the Particle. You can do this in the constructor of ParticleExplosion, and the only overhead is that only 1 extra object will be created (the others are copied from this). The boon is that you will lose all the tedious deletion, it will be safer if an exception is thrown...and IMO its simpler
Code:
#include <iostream>
#include <vector>
class foo{
public:
static int nObjCount;//Count of foo objects created
foo(){++nObjCount;}//Increase count for constructed obj
foo(const foo&){++nObjCount;}//Increase count for constructed obj
void Sing()const{std::cout << "Hello World" << std::endl;}
};
int foo::nObjCount;//Have to do this for static variable...sets to 0
class bar{
std::vector<foo> MyVector;//Internal Array
public:
bar(int n):MyVector(n,foo()){}//Make n copies of foo() in array
const foo& operator[](int i){return MyVector[i];}//Address bar with []
};
int main(int nArg,char** szArg){
const int nNoOfObj = 10;//How many objects
bar MyBar(nNoOfObj);//Make a bar with this many elements in array
for(int i = 0;i < nNoOfObj;++i)
MyBar[i].Sing();//cal function for each element of array
std::cout << "Total number of objects constructed ";
std::cout << foo::nObjCount << std::endl;//Count total number of object created for this
}
Notice that for 10 objects needed, only 1 extra (11 in total) is created...well worth the cost of this 1 temp object to get a safer & simpler model IMO