"==" operator error help

The error is:
error: no match for âoperator==â in â((University*)this)->University::departments.std::vector<_Tp, _Alloc>::operator[] [with _Tp = department, _Alloc = std::allocator<department>](((unsigned int)i)) == depIdâ

1
2
3
4
5
6
7
8
9
    for(int i=0; i<departments.size(); i++)
      {
        if(departments[i] == depId)
          {
            departments.erase(departments.begin()+1);
            return success;
          }
      }

I've never encountered this error before. Any help please?
Last edited on
- Your 'departments' vector is of type std::vector<department>
- This means departments[i] is of type department
- I'm guessing your depId is not of type department but is an integer or something.

You can't compare an integer to a department. You probably meant to do this:

1
2
3
4
if(departments[i].getId() == depId)
{
    ...
}
thanks, I forgot the .something after the [i]. no idea how i missed it. thanks a ton
Topic archived. No new replies allowed.