title: expected unqualified id before while c++
body: <p>I am making a simple C++ game based loosely on Starcraft. This is a way to practice pointers.</p>
  
  <p>The program works fine so now im adding the little technical stuff in this case, the Cloaking ability ghost</p>
  
  <p>In the ghost class, I set up a while loop for while bool cloak == true , you set the hits to blank as the ghost cant be hit while cloaked ( no detectors in this game) When i set it up, it gives me the error " expected unqualified id before while" .If i take out the loop, it doesnt give me an error.</p>
  
  <p>any help is much appreciated</p>
  
  <p>here is my ghost.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;ctime&gt;
  
  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 &amp;&amp; this-&gt;get_health()!=0 &amp;&amp; attacked_infantry-&gt;get_health()!=0)
      {
          attacked_infantry-&gt;SniperR_hit();
      }        
  }
  
  void ghost::attack(infantry* attacked_infantry)
  {
      shoot_SniperR(attacked_infantry);
  
      if (attacked_infantry-&gt;get_health() == 0)
          attacked_infantry-&gt;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) // &lt;-- 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 &lt;&lt; endl;
      infantry::print();
      cout &lt;&lt; "Sniper Rifle Rounds: " &lt;&lt; get_SniperR() &lt;&lt; endl;        
  }  
  
  void ghost::speak() const
  {
      infantry::speak();
      cout &lt;&lt; "Did somebody call for an exterminator? " &lt;&lt; endl;
  }
  
  void ghost::display() const
  {
      infantry::display();
      cout &lt;&lt; right &lt;&lt; setw(5) &lt;&lt; " "
           &lt;&lt; right &lt;&lt; setw(5) &lt;&lt; " "
           &lt;&lt; right &lt;&lt; setw(10) &lt;&lt; get_SniperR()
           &lt;&lt; endl;    
  } 
  </code></pre>