in a rut

I’m stuck. I’ve been trying to re-jigger my code to add a dialog asking for an ID number to delete from the vector and then doing it, but so far, I’ve gotten nowhere. Sure, I can create the dialog and get the info from the user, but I have not yet been able to use that info to selectively delete a clown from the car.

Recall, the purpose of this exercise is to ensure that I can handle a vector of objects, adding and deleting objects at will. A secondary objective is to be sure that I am assigning unique ID numbers to each object so they can be tracked accurately.

my function asking who to delete:

void askWhoToPop(vector<Clown> car){

    int popWho;

    cout<<“Please enter an ID number of a clown to kick out of the car: “;


    Clown::popThisClown(car, popWho);




my function for deleting an object:

void popThisClown(vector<Clown> car, int popWho){   //how to selectively delete from a vector????

for (int j = 0; j < car.size(); j++)


if(car[j].idNum == popWho)


delete car[j];



        }// end for





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: