title: Expected primary expression before * C++
body: <p>I can't figure out the error in the following code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  class Spell { 
      private:
          string scrollName;
      public:
          Spell(): scrollName("") { }
          Spell(string name): scrollName(name) { }
          virtual ~Spell() { }
          string revealScrollName() {
              return scrollName;
          }
  };
  
  class Fireball : public Spell { 
      private: int power;
      public:
          Fireball(int power): power(power) { }
          void revealFirepower(){
              cout &lt;&lt; "Fireball: " &lt;&lt; power &lt;&lt; endl;
          }
  };
  
  
  class SpellJournal {
      public:
          static string journal;
          static string read() {
              return journal;
          }
  }; 
  string SpellJournal::journal = "";
  
  void counterspell(Spell *spell) {
      if((Fireball *firespell=dynamic_cast&lt;Fireball*&gt;(spell))!=NULL)
      {
      firespell-&gt;revealFirepower();
  
  }
  
   else     
      {
  
  
      string scname=spell-&gt;revealScrollName();
      int m = scname.size();
      int n = SpellJournal::journal.size();
      int L[m+1][n+1];
      for(int i=0; i&lt;=m; i++)
      {
          for(int j=0; j&lt;=n; j++)
          {
              if(i==0 || j==0)
                  L[i][j] = 0;
              else if(scname[i-1]==SpellJournal::journal[j-1])
                  L[i][j] = L[i-1][j-1]+1;
              else
                  L[i][j] = max(L[i-1][j],L[i][j-1]);
          }
      }
      cout&lt;&lt;L[m][n];
  }
  
  }
  
  class Wizard {
      public:
          Spell *cast() {
              Spell *spell;
              string s; cin &gt;&gt; s;
              int power; cin &gt;&gt; power;
              if(s == "fire") {
                  spell = new Fireball(power);
              }
  
              else {
                  spell = new Spell(s);
                  cin &gt;&gt; SpellJournal::journal;
              }
              return spell;
          }
  };
  
  int main() {
      int T;
      cin &gt;&gt; T;
      Wizard Arawn;
      while(T--) {
          Spell *spell = Arawn.cast();
          counterspell(spell);
      }
      return 0;
  }  
  </code></pre>
  
  <p>The error is that primary expression is expected before * in the statement</p>
  
  <pre><code>if((Fireball *firespell=dynamic_cast&lt;Fireball*&gt;(spell))!=NULL)
  </code></pre>
  
  <p>also</p>
  
  <pre><code>firespell' was not declared in this scope
  </code></pre>
  
  <p>I think 2nd error is related to first. I don't know what concept I am missing. I have been following this link <a href="http://en.cppreference.com/w/cpp/language/dynamic_cast" rel="nofollow">http://en.cppreference.com/w/cpp/language/dynamic_cast</a></p>
  
  <p>kindly help.</p>