Question: Im having trouble with STl. Im trying to iterate through an STL list of student objects. Im trying to delete objects when I find a matching comparison. However I receive an error when doing the comparison. This is what I have done so far:

```
 string studentName;
                cout<<"Enter name of student to remove";
                cin>>studentName;

                list<Student>::iterator it = studentList.begin();
                while (it != studentList.end()){
                    if(*it== studentName){
                        studentList.erase(it);
                    }
                }

```

I get the error "Invalid operands to binary expression ('value\_type' (aka 'Student') and 'string' (aka 'basic\_string, allocator >'))"
I'm not quite sure how to solve it.
Thank you, any advice is appreciated!

Answer: 
You are comparing an instance of `Student` with an `std::string` which I'm assuming doesn't have a defined `operator==` overloaded function. You can either define this operator or compare `studentName` with the member string variable in `Student` which stores the name of the student. You might consider looking at `std::remove_if` in the algorithms library which you can use to filter out any students which don't have that name.
You are trying to compare a String and a Student. Also, you are not advancing the iterator, therefore that loop will fail to cease. Try something along these lines:

```
while (it != studentList.end()) {
    if(it->getName == studentName) {
        it = studentList.erase(it);
    }
    ++it;
}

```