小编ADA*_* GD的帖子

使用后的C++类声明

我想创建带有参数的方法,该参数链接到Enemy稍后声明的参数。\n这是我的代码:

\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};\n
Run Code Online (Sandbox Code Playgroud)\n

我尝试寻找答案,但没有发现任何有用的信息。\n以下是错误日志:

\n
prog.cpp:9:15: error: \xe2\x80\x98Entity\xe2\x80\x99 has not been declared\n   void Attack(Entity target){\n
Run Code Online (Sandbox Code Playgroud)\n

c++ class declaration header-files

1
推荐指数
1
解决办法
586
查看次数

标签 统计

c++ ×1

class ×1

declaration ×1

header-files ×1