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 3433748
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T07:36:51+00:00 2026-05-18T07:36:51+00:00

I’m currently having a problem with a class template in C++. I’m currently making

  • 0

I’m currently having a problem with a class template in C++. I’m currently making a hash table.

I’m using a functor as a class template to specify my hash function for each instance of a table.

IE: one table has integers for its keys, strings for its values. Another could have strings for its keys and integers for its values, etc…

class HashString
{
    public:
       unsigned long operator()(std::string& key, const unsigned int tableSize)
       {
           // .....
       }

};

template<typename keyType, typename valueType, class HashFunctor>
class HashTable
{
    public:
        // ....

    private:

        HashFunctor myHash;

};

And now let’s say I want to call the method called “myHash” to hash a key, I would at first call it by doing:

myHash(key, table.size())

But gcc doesn’t find a function overload for HashFuntor(string, unsigned int) for example.

Could someone tell me how I could call myHash?
(Note: I would not like to change my structure of functors)

edit: This is the error message I get from my actual solution

  instantiated from ‘void tp3::Table<TypeClef, TypeDonnee, FoncHachage>::insert(const TypeClef&, const TypeDonnee&) [with TypeClef = int, TypeDonnee = std::basic_string<char, std::char_traits<char>, std::allocator<char> >, FoncHachage = tp3::HacheString]’

no match for call to ‘(tp3::HacheString) (tp3::Table<int, std::basic_string<char, std::char_traits<char>, std::allocator<char> >, tp3::HacheString>::HashEntry&)’

Edit: Everywhere it says HacheString is in fact HashString (I’ve translated my code to paste it 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-05-18T07:36:52+00:00Added an answer on May 18, 2026 at 7:36 am

    operator() in HashString is private and is probably not const-correct. It should be a const member function taking const std::string& as its first parameter. The second parameter does not need to be const.

    You seem to be calling it with HashEntry as the second parameter. What is HashEntry? It takes an unsigned int!

    That might already solve some of your problems.

    I assume your HacheString / HashString difference is just a typo.

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

Sidebar

Related Questions

No related questions found

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.