Unable to use std::vector<>::iterator on a vector of pointers, "no suitable user-defined conversion"
Solution 1:
this
is a pointer to const Manager
, this->employees.begin();
returns std::vector<Employee*>::const_iterator
. The fix:
// std::vector<Employee*>::iterator i = this->employees.begin();
std::vector<Employee*>::const_iterator i = this->employees.begin();
Even better
auto i = this->employees.begin();
Solution 2:
You're calling begin()
from a const
method, so employees
is const, which means the begin()
overload that gets selected returns a std::vector<Employee*>::const_iterator
, not std::vector<Employee*>::iterator
. Change your variable declaration accordingly:
std::vector<Employee*>::const_iterator i = this->employees.begin();