How do I fix a “Expected Primary-expression before ‘)’ token” error?

showInventory(player); is passing a type as parameter. That’s illegal, you need to pass an object.

For example, something like:

player p;
showInventory(p);  

I’m guessing you have something like this:

int main()
{
   player player;
   toDo();
}

which is awful. First, don’t name the object the same as your type. Second, in order for the object to be visible inside the function, you’ll need to pass it as parameter:

int main()
{
   player p;
   toDo(p);
}

and

std::string toDo(player& p) 
{
    //....
    showInventory(p);
    //....
}

Leave a Comment