我经常在这个论坛上找到我的问题的答案,但这次我不能。这就是我问你的原因。 (提前抱歉我用英语或c ++做的错误)
所以这是我的虚空功能,它只是我在控制台制作的小游戏的开始。它只是展示了一些信息。顺便说一下,这是一场法国游戏,但我并不认为需要一个诱惑来解决我的问题。
void showIntro (Personnage a, Personnage b, Personnage c)
{
cout << endl;
cout << "VOUS ENTREZ DANS LES MINES DE LA MORIA" << endl << endl;
cout << "ENNEMIS PRESENTS : " << endl << endl;
cout << " " << "Orc robuste" << endl << endl << endl;
a.afficherEtatIntro ();
cout << endl << endl;
cout << " " << "Orc robuste" << endl << endl << endl;
b.afficherEtatIntro ();
cout << endl << endl;
cout << " " << "Orc robuste" << endl << endl << endl;
c.afficherEtatIntro ();
cout << endl << endl;
cout << "Le combat va commencer";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << ".";
Sleep(1000);
cout << "." << endl << endl << endl;
cout << "Gimli : ";
string phraseGimli ("Je vengerai mes freres!");
for (int f = 0; f <= phraseGimli.size(); f++) // Just writing a sentence
{
cout << phraseGimli[f];
Sleep(100);
}
cout << endl << "Legolas : ";
string phraseLegolas ("Nous sommes avec toi mon ami");
for (int g = 0; g <= phraseLegolas.size(); g++) // Writing a sentence
{
cout << phraseLegolas[g];
Sleep(100);
}
cout << endl << "Aragorn : ";
string phraseAragorn ("POUR LE GONDOR");
for (int i = 0; i <= phraseAragorn.size(); i++) // Writing a sentence
{
cout << phraseAragorn[i];
Sleep(100);
}
}
这是另一个。
void choixAttaque (Personnage joueur, Personnage a, Personnage b, Personnage c, string nom)
{
cout << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl << endl;
cout << "Qui souhaitez vous attaquer ?" << endl;
cout << endl;
cout << endl;
cout << " " << nom << endl << endl << endl;
a.afficherEtatIntro ();
cout << endl << "Tapez 1" << endl;
cout << " " << nom << endl << endl << endl;
b.afficherEtatIntro ();
cout << endl << "Tapez 2" << endl;
cout << " " << nom << endl << endl << endl;
c.afficherEtatIntro ();
cout << endl << "Tapez 3" << endl;
int choix;
do
{
cin >> choix;
} while (choix <= 0 || choix >= 4);
switch (choix)
{
case 1:
joueur.attaquer(a);
case 2:
joueur.attaquer(b);
case 3:
joueur.attaquer(c);
}
}
afficherEtatIntro()
void Personnage::afficherEtatIntro () const
{
cout << " " << "Vie : " << m_vie << endl;
cout << " ";
m_arme->afficher();
}
m_arme表示m_weapon,我使用&#34; - &gt;&#34;因为它来自指针。我对这一切都不熟悉,所以错误很可能来自这里。
当我只使用一个时,它可以正常工作,但是当我连续使用它们时,就会这样做。
first void function showing properly
然后。
我希望我提供解决问题所需的信息,我希望它能够得到解决。提前感谢所有事情,并抱歉我可能用英语,c ++或链接我的代码行所犯的所有错误。 ^^&#39; (顺便说一下,所有的&#34; cout&lt;&lt; endl;&#34;看起来很难看,但这只是在我学习如何使用Qt之前......)
来自调试器:&#34;编程接收信号SIGSEGV,分段故障。&#34; 还有评论中的图片。 (3个链接需要更多声望..)