所以我幾乎完成了這個任務,但現在我又遇到了困難。當我嘗試從問題類中繪製文本時,我從xstring獲得無效的空指針。我有大約2個小時,所以任何幫助真的理解xstring中的無效空指針
這裏的問題類:
class Question {
public:
int col;
int row;
bool dailyDouble;
char* question;
char* answer;
double value;
Question();
Question(int, int, bool, char*, char*);
bool checkAnswer(string);
Question& operator=(const Question&);
};
Question::Question() {}
Question::Question(int c, int r, bool d, char* q, char* a)
{
col = c; row = r; dailyDouble = d; question = q, answer = a;
if(d)
value = r * 200 * 2;
else
value = r * 200;
}
bool Question::checkAnswer(string answer)
{
if(answer.find("What is") && answer.find(answer))
return true;
return false;
}
Question& Question::operator=(const Question&)
{
return *this;
}
我有一個畫文本方法(的作品),但我跑出來的空間,所以這是導致錯誤的行:
drawText((WinWidth/2)-200,(WinHeight/2) - 100, curQuestion.question);
任何幫助將真正感激!
運行在哪裏的房間? SO編輯器滾動,你知道! – 2011-05-17 10:13:10
什麼是詢問?指針在哪裏?在調試器中運行應用程序,並在它聲明時按下重試按鈕。它會帶你到問題的路線。你可以檢查Call Stack窗口來查看調用堆棧中的以前方法 – 2011-05-17 10:14:12