Template class with "typename"
<p>I have a template class where I want to use objects of that class (along with the parameterized type) inside a map. So far this is the solution that I've been able to arrive at:</p>

<pre><code>class IStatMsg;

template &lt;typename T&gt;
class ITier
{
public:

    // Methods
    ITier(TierType oType) : o_Type(oType){};
    virtual ~ITier(){};

    typename ITier&lt;T&gt; ParamITier;  // line 60

    ITier* Get(T oKey)
    {
     std::map&lt;T, ParamITier*&gt;::iterator it = map_Tiers.find(oKey); // line 64

     if (it != map_Tiers.end())
      return it-&gt;second;

     return NULL;
    }

    void Set(T oKey, ITier* pTier)
    {
     map_Tiers.insert(pair&lt;T, ParamITier*&gt;(oKey, pTier)); // line 74
    }

    TierType GetType() { return o_Type; }

protected:
    // Methods

    // Attributes
    std::map&lt;T, ParamITier*&gt; map_Tiers;  // line 83
    TierType o_Type;

private:
    // Methods

    // Attributes
};
</code></pre>

<p>But when I try to compile this code I get a long list of errors:</p>

<blockquote>
  <p>/home/gayanm/street/src/QueryServer_NEW/ITier.h:60:
  error: expected nested-name-specifier
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:60:
  error: <code>ITier&lt;T&gt;' specified as
  declarator-id
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:60:
  error:   perhaps you want </code>ITier'
  for a constructor
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:60:
  error: two or more data types in
  declaration of <code>ITier&lt;T&gt;'
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:60:
  error: expected </code>;' before
  "ParamITier"
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:83:
  error: <code>ParamITier' was not declared
  in this scope
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:83:
  error: template argument 2 is invalid
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:83:
  error: template argument 4 is invalid
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:83:
  error: ISO C++ forbids declaration of
  </code>map_Tiers' with no type
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:
  In member function <code>ITier&lt;T&gt;*
  ITier&lt;T&gt;::Get(T)':
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:64:
  error: </code>ParamITier' undeclared (first
  use this function)
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:64:
  error: (Each undeclared identifier is
  reported only once for each function
  it appears in.)
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:64:
  error: template argument 2 is invalid
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:64:
  error: template argument 4 is invalid
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:64:
  error: expected <code>;' before '::' token
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:66:
  error: </code>it' undeclared (first use this
  function)
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:66:
  error: request for member <code>end' in
  </code>((ITier*)this)->ITier::map_Tiers',
  which is of non-class type <code>int'
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:
  In member function </code>void
  ITier::Set(T, ITier*)':
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:74:
  error: request for member <code>insert' in
  </code>((ITier*)this)->ITier::map_Tiers',
  which is of non-class type <code>int'
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:74:
  error: </code>pair' undeclared (first use
  this function)
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:74:
  error: expected primary-expression
  before ',' token
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:74:
  error: <code>ParamITier' undeclared (first
  use this function)
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:74:
  error: expected primary-expression
  before '&gt;' token
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:
  At global scope:
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:93:
  error: base </code>ITier' with
  only non-default constructor in class
  without a constructor
  /home/gayanm/street/src/QueryServer_NEW/ITier.h:109:
  error: expected class-name before '{'
  token</p>
</blockquote>

<p>Could you please point out how to fix these?</p>

<p>Thank You.</p>
