我已经尝试了很多事情,但我一直收到同样的错误。首先,我想说我没有从事任何与口袋妖怪相关的工作,因为我的技能显然不够好,这只是我能想到的最实际的例子,可以让别人明白这一点.
struct pokeDex {
struct pokemonTemplate {
std::string pokemonName;
std::string pokemonMoves[3];
int pokemonLevel;
int baseATK;
int baseDEF;
int baseSPATK;
int baseSPDEF;
int baseSPEED;
};
pokemonTemplate Bulbasaur;
Bulbasaur.pokemonName = "Bulbasaur";
Bulbasaur.pokemonLevel = 5;
Bulbasaur.baseATK = Bulbasaur.pokemonLevel * 10;
Bulbasaur.baseDEF = Bulbasaur.pokemonLevel * 10;
Bulbasaur.baseSPATK = Bulbasaur.pokemonLevel * 10;
Bulbasaur.baseSPDEF = Bulbasaur.pokemonLevel * 10;
Bulbasaur.baseSPEED = Bulbasaur.pokemonLevel * 10;
pokemonTemplate Pikachu;
Pikachu.pokemonName = "Pikachu";
Pikachu.pokemonLevel = 5;
Pikachu.baseATK = Pikachu.pokemonLevel * 7;
Pikachu.baseDEF = Pikachu.pokemonLevel * 10;
Pikachu.baseSPATK = Pikachu.pokemonLevel * 12;
Pikachu.baseSPDEF = Pikachu.pokemonLevel * 6;
Pikachu.baseSPEED = Pikachu.pokemonLevel * 15;
};
我不断收到错误“错误:“Bulbasaur”/“Pikachu”没有命名类型。” 我已经看到了多个关于此的问题,但没有一个能解决它。我尝试将结构分开,并仅引用 pokeDex 结构中的 pokemonTemplate 结构,但这不起作用。
我还尝试将 pokeDex 设为类而不是结构,并且尝试将 pokemonTemplate 结构置于类外部和类内部,但我继续收到错误消息。每次,我在引用它之前都小心地定义了 pokemonTemplate 结构,但我一定做错了什么。