私はStarcraftで簡単にC++の簡単なゲームを作っています。これはポインタを練習する方法です。C++の間に予期されていないIDが予期される
プログラムは罰金が今イムこの場合、クローキング能力ゴーストゴーストクラスで
に少し技術的なものを追加動作しますが、私はブールマントが== trueの場合、あなたが設定されている間のためにwhileループを設定しました私はそれを設定すると、それは私にエラー "私の前に未修飾のIDが期待されて"を与える。私はループを取る、それは私にエラーを与えません(私はそれを設定するときに幽霊は、 。
任意のヘルプはずっとここに
を高く評価され、これを行うための適切な方法は、whileループを削除し、マントは、あなたの方法で真であるかどうかを確認するためである私のghost.cpp
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
#include "ghost.h"
ghost::ghost(string iname, string iteam, string itype, int Snipe, bool cloak)
: infantry(iname, iteam, itype)
{
set_SniperR(Snipe);
set_Cloak(cloak);
set_health(80);
}
void ghost::set_SniperR(int Snipe)
{
SniperR = Snipe;
}
int ghost::get_SniperR() const
{
return SniperR;
}
void ghost::shoot_SniperR(infantry* attacked_infantry)
{
if(SniperR!=0 && this->get_health()!=0 && attacked_infantry->get_health()!=0)
{
attacked_infantry->SniperR_hit();
}
}
void ghost::attack(infantry* attacked_infantry)
{
shoot_SniperR(attacked_infantry);
if (attacked_infantry->get_health() == 0)
attacked_infantry->die();
}
void ghost::heal(infantry* attacked_infantry) { }
void ghost::die()
{
set_SniperR(0);
}
void ghost::set_Cloak(bool cloak)
{
Cloak = cloak;
}
bool ghost::get_Cloak() const
{
return Cloak;
}
while (cloak) // <-- error
{
void ghost::AssaultR_hit()
{
// when cloak is on , AssaultR doesnt affect Ghost
}
void ghost::FlameT_hit() { }
void ghost::SniperR_hit() { }
void ghost::RocketL_hit() { }
void ghost::StickyG_hit() { }
}
void ghost::print() const
{
cout << endl;
infantry::print();
cout << "Sniper Rifle Rounds: " << get_SniperR() << endl;
}
void ghost::speak() const
{
infantry::speak();
cout << "Did somebody call for an exterminator? " << endl;
}
void ghost::display() const
{
infantry::display();
cout << right << setw(5) << " "
<< right << setw(5) << " "
<< right << setw(10) << get_SniperR()
<< endl;
}
関数の中で 'while 'を使うことはできません。 – DimChtz
改行を責任感を持って賢明に使用してください。 –