我必须在C++中做一个练习,我有一个这样的数组结构,我从来没有见过它,我不知道如何使用它,如果有人请解释我。如何使用这种类型的数组,struct
struct Fighter{
string type; // TIE Fighter, X-Wing, ...
int velocity;
int attack; // attack power
int shield; // current shield status.
int cost; // cost in credits};
const Fighter FIGHTERTABLE[] = {
{ "TIE-Fighter", 150, 75, 30, 45 },
{ "TIE-Bomber", 80, 150, 45, 75 },
{ "TIE-Interceptor", 180, 65, 30, 55 },
{ "TIE-Advanced", 160, 80, 90, 95 },
{ "X-Wing", 175, 90, 75, 65 },
{ "Y-Wing", 90, 150, 90, 90 },
{ "A-Wing", 200, 60, 50, 45 },
{ "B-Wing", 120, 200, 90, 100 }
};
const string FIGHTERABR[]= { "tf", "tb", "ti", "ta",
"xw", "yw", "aw", "bw"
};
请张贴代码不打印屏幕 –
不要张贴代码的*图片*,特别是作为可以陈旧的链接。而是将实际文本复制到问题的正文中。请[阅读关于如何提出好问题](http://stackoverflow.com/help/how-to-ask)。您可能还想了解如何创建[最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。并且不要使用不相关的语言标记,如果您使用C++进行编程,请不要添加C标记。 –
至于你的问题,你有*以前使用过结构吗?你有*以前使用过数组吗?然后结合你已有的知识。 –