【发布时间】:2012-11-20 23:06:05
【问题描述】:
我遇到了一个错误,我在 cpp 文件中的“使用”函数中不断收到“不是类型名称”。我正在尝试制作一个结构数组,以存储“项目”的数据。我正在制作一个基于文本的 RPG 游戏,所以我正在尝试创建一个具有使用功能的项目类,以在角色上使用各种项目(在结构数组中)。我试过用几种不同的方式编写它并以其他方式调用它,但我无法让这个错误消失。甚至将结构放在类之前,公开等。
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
}
【问题讨论】:
-
eating useables[10];在做什么? -
@SidharthMudgal 创建一个饮食结构数组
标签: arrays class function struct