错误1错误C3867:'Command :: getSecondWord':函数调用缺少参数列表;使用“&”创建指向成员的指针

sparky971

我真的快要完成我的项目了,但是我遇到了一个错误,就是无法解决问题。

它告诉我使用&sign创建指向成员的指针。

void Inventory::eat(string food){
//takes in the string stores it in temp string  call isitemin inventory to return an int
//use that int to return isEdible, int = 2 means your checking at pos 2
//if edible remove from inventory and add 2hp
string tempString = food;
int checker=isItemInventory(tempString);
bool edible = inventory[checker].getEdible;
if (!edible){
    cout << "you can't eat " + food << endl;
}
else//ended here for now

所以基本上我有一个eat函数,它接受一个字符串,它将字符串存储在tempstring中,然后使用isItemInventory()返回一个数字。这个数字告诉我们试图吃的物品在“库存”向量中的位置。获得该数字后,我们将创建一个本地布尔值,并在该项目上调用getEdible。这应该返回true或false,但是我收到有关使用指针的错误?谁能帮我吗 ?

乔纳森·波特(Jonathan Potter)

您可能想要:

bool edible = inventory[checker].getEdible();
                                       // ^^ parentheses are needed to call a function

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

Related 相关文章

热门标签

归档