0

I am trying to create a function that takes in a sorted vector of integers, loops through the vector and if there is a value in the vector that is repeated it deletes that entry.

This is what I have so far and I am not too sure how to correct the function to get it working as I get the following error message:

error: type 'int' argument given to 'delete', expected pointer

void checkID(vector <int>& d){

    for (unsigned int i = 0; i < d.size(); i++){
        if(d[i] == d[i+1]){
            delete d[i+1];
        }
    }
}

Please help!

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by shahramjaved
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.