i'm having a problem erasing a vector element.
The error i get is the following:
"no match for 'operator+' in '((CStudent*)this)->CStudent::objects.std::vector<_Tp, _Alloc>::begin<Object, std::allocator<Object> > () + item"
The erase function takes an iterator to the element that should be removed as argument.
object.begin() returns an iterator to the first element in the vector. By adding an index you get an iterator to the element at that index position. Example: object.begin() + 3 gives you an iterator to object[3].
item is not an index. You probably will have to search the vector to find the position before calling erase.
If you use a loop you can put an if statement inside the loop to test if the item is equal to the item that you want to erase. When you have found the item you pass the iterator (or the object.begin() + index) to the erase function. After you have done that you make the loop stop by using break;
What about if i want to remove the object by name and not by an index?
You are not removing element by index. You are removing element (single element) which equals to passed one. Use find_if: http://en.cppreference.com/w/cpp/algorithm/find
To find element satisfying specific condition instead.