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

Error 1 error C3867: 'Command::getSecondWord': function call missing argument list; use '&' to create a pointer to member

本文关键字:错误 创建 指针 成员 使用 参数 命令 C3867 getSecondWord 函数调用 列表      更新时间:2023-10-16

我真的快要完成我的项目了,但我遇到了一个错误,我简直无法理解。

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

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()返回一个数字。这个数字告诉我们该物品试图吃的向量"库存"中的abouts所在的位置。一旦我们有了这个数字,我们就会创建一个本地布尔值,并对该项调用getEdible。这应该返回true或false,但我却收到了一个关于使用指针的错误?有人能帮我吗?

您可能想要:

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