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