2015-01-16 36 views
1

您能否解释为什么会发生以下错误,以及如何解决该问题?它给了我一个很大的问题,所以请我需要你的帮助将'this'指针从项目转换为const项目和编译器错误

错误(编译错误) -

the object has type qualifiers that are not compatible with the member function

*的项目成员是一组

问题线 -

temp.setName(items.find(itemList[option])->getName()); 

setName和getName函数 -

void Item::setName(string name) 
{ 
    this->_name = name; 
} 
string Item::getName() 
{ 
    return this->_name; 
} 

回答

3

您的方法不是const正确的。该设置将只允许它的内容不变的方法:

string Item::getName() const 
{ 
    return this->_name; 
} 
+0

感谢所有工作良好(; – Alon