error C2440

Posted 邓戈麟

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了error C2440相关的知识,希望对你有一定的参考价值。

 

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);
		}

 

以上是关于error C2440的主要内容,如果未能解决你的问题,请参考以下文章

error C2440: “=”: 无法从“const wchar_t [4]”转换为“LPWSTR”

error C2440: “=”: 无法从“const char [18]”转换为“LPCWSTR”

error C2440: “=”: 无法从“const char [18]”转换为“LPCWSTR”

C++调试 错误error C2664 er ror C2440 求帮主

error C2440: “static_cast”: 无法从“void (__thiscall CMainFrame::* )

error C2440: "=": 无法从"char *"转换为"LPTSTR" LPTSTR buffer; buffer = new c