// PL4/class5.cpp // An example using a vector of objects // Niels Walet, last updated 04/12/2019 #include #include #include #include using namespace std; class particle { private: string type; double mass; double momentum; double energy; public: // Default constructor particle() : type{"Ghost"}, mass{}, momentum{}, energy{} {} // Parameterized constructor particle(string particleType, double particleMass, double particleMomentum) : type{particleType}, mass{particleMass}, momentum{particleMomentum}, energy{sqrt(particleMass*particleMass+particleMomentum*particleMomentum)} {} ~particle(){cout<<"Destroying "< particle_data; particle_data.push_back(particle("electron",5.11e5,1.e6)); particle_data.push_back(particle("proton",0.938e9,3.e9)); //vector::iterator particle_it; for(auto particle_it=particle_data.begin(); particle_itprint_data(); cout<<"has Lorentz factor gamma="<gamma()<