[英]Error 1 error C3867: 'Command::getSecondWord': function call missing argument list; use '&' to create a pointer to member
I'm really close to finishing my project, but i'm running into an error that I just can't wrap my head around. 我真的快要完成我的项目了,但是我遇到了一个错误,就是无法解决问题。
It's telling me to use & sign to create a pointer to member. 它告诉我使用&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
So basically i have an eat function that takes in a string, it stores the string in tempstring and then uses isItemInventory() to return a number. 所以基本上我有一个eat函数,它接受一个字符串,它将字符串存储在tempstring中,然后使用isItemInventory()返回一个数字。 This number tells us where abouts in the vector "inventory" that the item were trying to eat is located. 这个数字告诉我们试图吃的物品在“库存”向量中的位置。 Once we have that number we create a local boolean and call getEdible on the item. 获得该数字后,我们将创建一个本地布尔值,并在该项目上调用getEdible。 this should return true or false but instead i'm getting an error about using a pointer ? 这应该返回true或false,但是我收到有关使用指针的错误? can anyone help me out ? 谁能帮我吗 ?
You probably want: 您可能想要:
bool edible = inventory[checker].getEdible();
// ^^ parentheses are needed to call a function
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.