Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:23:08+00:00 2026-05-11T03:23:08+00:00

I have a template class where I want to use objects of that class

  • 0

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:

class IStatMsg;  template <typename T> class ITier { public:      // Methods     ITier(TierType oType) : o_Type(oType){};     virtual ~ITier(){};      typename ITier<T> ParamITier;  // line 60      ITier* Get(T oKey)     {         std::map<T, ParamITier*>::iterator it = map_Tiers.find(oKey);   // line 64          if (it != map_Tiers.end())             return it->second;          return NULL;     }      void Set(T oKey, ITier* pTier)     {         map_Tiers.insert(pair<T, ParamITier*>(oKey, pTier)); // line 74     }      TierType GetType() { return o_Type; }  protected:     // Methods      // Attributes     std::map<T, ParamITier*> map_Tiers;  // line 83     TierType o_Type;  private:     // Methods      // Attributes }; 

But when I try to compile this code I get a long list of errors:

/home/gayanm/street/src/QueryServer_NEW/ITier.h:60: error: expected nested-name-specifier /home/gayanm/street/src/QueryServer_NEW/ITier.h:60: error: ITier<T>' specified as declarator-id /home/gayanm/street/src/QueryServer_NEW/ITier.h:60: error: perhaps you wantITier’ for a constructor /home/gayanm/street/src/QueryServer_NEW/ITier.h:60: error: two or more data types in declaration of ITier<T>' /home/gayanm/street/src/QueryServer_NEW/ITier.h:60: error: expected;’ before ‘ParamITier’ /home/gayanm/street/src/QueryServer_NEW/ITier.h:83: error: 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 map_Tiers’ with no type /home/gayanm/street/src/QueryServer_NEW/ITier.h: In member function ITier<T>* ITier<T>::Get(T)': /home/gayanm/street/src/QueryServer_NEW/ITier.h:64: error: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 ;' before '::' token /home/gayanm/street/src/QueryServer_NEW/ITier.h:66: error:it’ undeclared (first use this function) /home/gayanm/street/src/QueryServer_NEW/ITier.h:66: error: request for member end' in ((ITier)this)->ITier::map_Tiers’, which is of non-class type int' /home/gayanm/street/src/QueryServer_NEW/ITier.h: In member functionvoid ITier::Set(T, ITier)’: /home/gayanm/street/src/QueryServer_NEW/ITier.h:74: error: request for member insert' in ((ITier*)this)->ITier::map_Tiers’, which is of non-class type int' /home/gayanm/street/src/QueryServer_NEW/ITier.h:74: error: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: ParamITier' 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: At global scope: /home/gayanm/street/src/QueryServer_NEW/ITier.h:93: error: baseITier’ 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

Could you please point out how to fix these?

Thank You.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:23:09+00:00Added an answer on May 11, 2026 at 3:23 am

    Line 60 does not access a depending name. What you use is ITier<T> of which the compiler knows it’s a template given an argument. Instead of typename you want to use typedef 😉

    Line 64 does access the depending name iterator which is a type-name, so you have to put typename before std::map. I put the two disambiguations, template and typename on this answer: Disambiguations of dependent names.

    Line 74 would be right, if you fix the bug in Line 60, as far as i can see.

    Line 83 is alright in itself as far as i can see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Check the accepted solution at: http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/Q_21968000.html If the authentication ticket… May 11, 2026 at 12:37 pm
  • added an answer const str = 'hello,how,are,you,today?' const pieces = str.split(/[\s,]+/) const last… May 11, 2026 at 12:37 pm
  • added an answer A VB.NET version of allclaws' method: Function ContainsText(ByVal fileName As… May 11, 2026 at 12:37 pm

Related Questions

I have a template class that I serialize (call it C), for which I
I have a template class like below. template<int S> class A { private: char
I have a template class that is only valid for couple of template parameters:
I have a template class for thread-safe vector: template <class T> class SharedVector {
NOTE I have asked the related question: How to combine DataTrigger and EventTrigger? I
Answered : They don't allow any kind of redistribution with 2.6, supposedly, unless you
This question is related to (but perhaps not quite the same as): Does Django

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.