I am concerned about creating and then pushing the dynamic objects into vector of pointers. I would like to know how to implement this correctly to avoid any kind of memory leaks. Here's what I have:
//THIS CREATES VECTOR
vector <combustion_car*> combustion_car_list;
//THIS IS CREATING AND PUSHING THE OBJECT
combustion_car* temporary=new combustion_car;
temporary->create();
combustion_car_list.push_back(temporary);
cout<<"Object added"<<endl;
temporary=NULL;
delete temporary;
//THIS DELETES OBCJET FROM VECTOR
combustion_car_list.erase(combustion_car_list.begin() + (choice-1));