我想创建带有参数的方法,该参数链接到Enemy稍后声明的参数。\n这是我的代码:
#include <iostream>\n#include <vector>\nusing namespace std;\nclass Weapon{\n public:\n int atk_points;\n string name;\n string description;\n void Attack(Entity target){\n \n };\n};\nclass Armor{\n public:\n int hp_points;\n string name;\n string description;\n int block_chance;\n};\nclass Entity{\n public:\n int hp;\n int atk;\n string name;\n vector<Weapon> weapons;\n vector<Armor> armors;\n};\nRun Code Online (Sandbox Code Playgroud)\n我尝试寻找答案,但没有发现任何有用的信息。\n以下是错误日志:
\nprog.cpp:9:15: error: \xe2\x80\x98Entity\xe2\x80\x99 has not been declared\n void Attack(Entity target){\nRun Code Online (Sandbox Code Playgroud)\n