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

  • SEARCH
  • Home
  • 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 7919195
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:47:02+00:00 2026-06-03T15:47:02+00:00

I am trying to implement a generic hashlist class using templates and I am

  • 0

I am trying to implement a generic hashlist class using templates and I am trying to inherit from the base class but getting lots of compile errors. Here is my code:

#ifndef BASEHASHLIST_H_
#define BASEHASHLIST_H_

#include <string>
#include <boost/unordered_set.hpp>
#include <iostream>
#include <boost/interprocess/sync/interprocess_semaphore.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>



    template <typename T>
    class BaseHashList
    {

    private:
        boost::interprocess::interprocess_semaphore m_semaphore;

    protected:

        boost::unordered_set<T> m_hsHashSet;                
        typename boost::unordered_set<T>::iterator m_hsIter;            
    public:

        BaseHashList();
    };

    template <typename T>
    BaseHashList<T>::BaseHashList():m_semaphore(1){}

#endif /* BASEHASHLIST_H_ */

And here is the class that is inheriting from the base class:

#ifndef ACCOUNTLIST_H_
#define ACCOUNTLIST_H_

#include "BaseHashList.h"

    class AccountList : public BaseHashList<unsigned long>
    {
    public:
        AccountList(std::string p_strFile, unsigned long p_ulMaxAccountNo);
        ~AccountList(void);

        int m_iVersion;
        std::string m_strFilePath;


    private:
        unsigned long m_ulMaxAccountNo;
    };


#endif /* ACCOUNTLIST_H_ */

and here is the cpp file:

#include "AccountList.h"

AccountList::AccountList(std::string p_strFile, unsigned long p_ulMaxAccountNo)
: BaseHashList<unsigned long>::m_hsHashSet<unsigned long>(),
  m_iVersion(0),
  m_strFilePath(p_strFile)
{
    m_ulMaxAccountNo = p_ulMaxAccountNo;
}


AccountList::~AccountList(){}

I am receiving a lot of compile time errors such as:

expected template-name before token ‘<‘
expected ‘(‘ before token ‘<‘

For such a simple task I spent couple of hours and I am super frustrated, does anybody see what I am doing wrong here?

  • 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. Editorial Team
    Editorial Team
    2026-06-03T15:47:05+00:00Added an answer on June 3, 2026 at 3:47 pm

    This initaliser in AccountList‘s constructor looks wrong to me:

    BaseHashList<unsigned long>::m_hsHashSet<unsigned long>()
    

    You should initalise the members of BaseHashList inside a constructor of BaseHashList itself, one will always either explicitly or implicitly be called.

    This example is simplified and similarly wrong:

    struct A {
      int bar;
    };
    
    struct B : A {
      B() : A::bar(0) {}
    };
    

    (saying bar(0) would also be wrong there)

    However you can get the desired behaviour:

    struct A {
      A() : bar(0) {}
      int bar;
    };
    
    struct B : A {
      B() {} // Implicitly calls A::A although we could have explicitly called it
    };
    

    The constructor of A gets called and given a chance to initalise its members here still.

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

Sidebar

Related Questions

I am trying to implement a generic Wrapper-Class for Qt's class system using C#'s
I'm trying to implement the repository pattern using a generic repository like the one
I'm trying to implement an identity map using generics. I have an abstract class,
I'm trying to implement a class that stores a generic nullable type: public class
I am trying to implement a new class inherited from List<string> , to load
I am trying to implement an inner class that has a generic parameterized type.
I am currently trying to implement a serial port reader class using Windows (already
I'm trying to build a generic class to work with entities from EF. This
I am trying to implement a generic abstract class in my service layer. I
I'm trying to implement multicolumn filtering using LINQ expressions in a class that extends

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.