I’ve ran into an error where I keep getting “is not a type name” for the ‘use’ function in the cpp file. I’m trying to make an array of structs, to store data for “Items”. I’m making a text based RPG game, so I’m trying to create an item class, that has a use function, to use the various items (In the struct array) on the characters. I’ve tried writing this several different ways and calling it other ways, but I can’t get this error to go away. Even placing the struct before the class, in the public, etc.
class Items
{
private:
struct eating
{
int itemNumber;
char name[30];
};
public:
Items();
eating useables[10];
void use(useables);
};
void Items::use(useables) // Error is here, tells me useables is not a type name
{
// To use items on characters
}
You need to pass a type and a name to your function:
In the case you just wanted to use the internal
useablesobject, you don’t need to pass it to the function and can just write