error C2440: “初始化”: 无法从“std::_List_const_iterator<std::_List_val<std::_List_simple_types<Observer *>>>”转换为“std::_List_iterator<std::_List_val<std::_List_simple_types<Observer *>>>”
如果传递过来是一个const类型的容器,那么只能用const_iterator进行遍历
for (std::list<Observer *>::const_iterator it = m_observers.begin(); it != m_observers.end(); ++it) { Observer *obj = *it; obj->update(m_temperature, m_humidity, m_pressure); }