转换这个'指针从项目到const项目&编译器错误

时间:2015-01-16 16:47:21

标签: c++ function compiler-errors set

您能解释一下为什么会出现以下错误以及如何解决问题?它给了我很多问题,所以我需要你的帮助

错误(编译错误) -

  

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

1 个答案:

答案 0 :(得分:3)

您的方法不是常量。该集合只允许对其内容采用常量方法:

string Item::getName() const
{
    return this->_name;
}
相关问题