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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:28:05+00:00 2026-05-30T23:28:05+00:00

How would I implement an Array of Hashtables in c++? I have a hashtable

  • 0

How would I implement an Array of Hashtables in c++?

I have a hashtable class with a constructor that looks like this:

explicit ChainingHashTable( const HashedObj & notFound, int size = 101 );

So I attempted making an array of these hashtables by doing:

static ChainingHashTable<int> answers[5] = { {0, 500}, {0, 500}, {0, 500}, {0, 500}, {0, 500} };

however, I get the following errors & warnings:

browser.cpp:106:71: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
browser.cpp:106:71: error: converting to ‘ChainingHashTable<int>’ from initializer list would use explicit constructor ‘ChainingHashTable<HashedObj>::ChainingHashTable(const HashedObj&, int) [with HashedObj = int]’

I can’t use a different compiler since this is for a class assignment, but what am I doing incorrectly? What’s the proper syntax?

  • 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-30T23:28:06+00:00Added an answer on May 30, 2026 at 11:28 pm

    Have you tried

    static ChainingHashTable<int> answers[5] = { ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500) };
    

    ?


    Above is the method for a global variable. For a static class member, the declaration and definition must be separate:

    class SomeClass
    {
        static ChainingHashTable<int> answers[5];
    };
    

    and in one compilation unit (so not inside a header)

    ChainingHashTable<int> SomeClass::answers[5] = { ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500), ChainingHashTable<int>(0, 500) };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, i would like to implement something like this: class Collection{ private $array; public
I would like to implement a template which contains an array of the template
How would i implement this?Im trying to compare a array of c strings to
I would like to implement a binary search algorithm in Perl. My 'array' is
I would like to implement the Ramer–Douglas–Peucker_algorithm in C++. The pseudo code looks like
How would I implement a binary search using just an array?
When would I implement IDispose on a class as opposed to a destructor? I
I would like to implement a save feature, which allows my users to save
I'd like to implement a big int class in C++ as a programming exercise—a
I would like to implement a RTE (Rich Text Editor) with the ability to

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.