0
我只是C++的新手,请耐心等待。在我的班级MyArena
里面,我制作了另一个班级的指针fighters
的矢量,Fighter
。有了这个矢量,我正在收集战斗机指针并为它们调用函数。但我不断收到错误fighters
。从指针调用函数向量
#include <vector>
using namespace std;
class Fighter;
class MyArena {
vector<Fighter*> fighters;
int current_size = 0;
bool MyArena :: addFighter(string info){
for (int i = 0; i < 11; i++){
if (fighters[i]->getName() == n) //error that "point to incomplete pass type is not allowed?"
isLegit = false;
}
fighters.push_back(new Fighter(n, t, mH, st, sp, m)); //"Fighter" is incomplete type?
return true;
}
bool removeFighter(string name){
for (int i = 0; i < 11; i++){
if (fighters[i]->getName() == name)//error that "point to incomplete pass type is not allowed?"
fighters[i] = NULL;
}
}
};
我该如何解决这个问题?
“战斗机”未定义。将成员函数定义移出标题并放入'.cpp'文件中。 – 2014-09-05 23:32:16
'寻求调试帮助的问题(“为什么这个代码不工作?”)必须包含所需的行为,特定的问题或错误以及在问题本身中重现问题所需的最短代码。没有明确问题陈述的问题对其他读者没有用。请参阅:[如何创建最小,完整和可验证示例。](http://stackoverflow.com/help/mcve) – 2014-09-05 23:33:24