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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:06:29+00:00 2026-06-02T17:06:29+00:00

I am getting an error on the constructor for my hash table class, which

  • 0

I am getting an error on the constructor for my hash table class, which is a vector of ‘Entry’ objects ( class definition below ).

HT::HT (  const unsigned& s )
{
    hTable = new Entry[s];
    pTable = new Entry*[s];
    psize = 0;
    hsize = TBL_SZ;
    for (unsigned int i = 0; i != s; i++)
    {
        hTable[i].key = FREE;
    }
}

Why am i getting this error?

    hTable.cc:12:15: error: expected type-specifier before âhTableâ
hTable.cc:12:15: error: no match for âoperator=â in â((HT*)this)->HT::hTable = (int*)operator new(4u)â
hTable.cc:12:15: note: candidate is:
/usr/include/c++/4.6/bits/vector.tcc:158:5: note: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = Entry, _Alloc = std::allocator<Entry>]
/usr/include/c++/4.6/bits/vector.tcc:158:5: note:   no known conversion for argument 1 from âint*â to âconst std::vector<Entry>&â
hTable.cc:12:15: error: expected â;â before âhTableâ
hTable.cc:13:15: error: expected type-specifier before âpTableâ
hTable.cc:13:15: error: no match for âoperator=â in â((HT*)this)->HT::pTable = (int*)operator new(4u)â
hTable.cc:13:15: note: candidate is:
/usr/include/c++/4.6/bits/vector.tcc:158:5: note: std::vector<_Tp, _Alloc>& std::vector<_Tp, _Alloc>::operator=(const std::vector<_Tp, _Alloc>&) [with _Tp = Entry*, _Alloc = std::allocator<Entry*>]
/usr/include/c++/4.6/bits/vector.tcc:158:5: note:   no known conversion for argument 1 from âint*â to âconst std::vector<Entry*>&â

Here is the header file:

    #ifndef H_HASH_TABLE
#define H_HASH_TABLE

// class for hash table

class HT {
public:
    HT ( const unsigned& = TBL_SZ ); // constructor
    ~HT ( );                         // destructor

    void insert ( const Entry& );    // inserts item in hash table
    void search ( const string& );   // searches for item

    void hTable_print ( ); // prints hash table entries
    void pTable_print ( ); // prints hash table entries in sorted order

private:
    unsigned hsize,             // size of hash table
             psize;             // actual size of ptr table

    vector < Entry >  hTable;   // hash table
    vector < Entry* > pTable;   // ptr table

    int hash ( const string& ); // hash function
};
#endif

Here is my Entry object header:

#ifndef H_ENTRY
#define H_ENTRY

#define ID_SZ    3      // size of key
#define ITEM_SZ 24      // max size for item description 
#define TBL_SZ  31      // default size for hash table
#define FREE   "$$$"    // indicates empty spot in hash table

// entry in hash table

struct Entry {
    string key;   // key
    string desc;  // description
    unsigned num; // no of copies

    //constructor
    Entry ( const string& k = FREE, const string& d = "",
        const unsigned& n = 0 ) : key ( k ), desc ( d ),
        num ( n ) { }
};
#endif
  • 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-02T17:06:31+00:00Added an answer on June 2, 2026 at 5:06 pm

    new Entry[s]; creates an array of Entry objects and you are trying to assign it to a vector. The same goes with new Entry*[s] . You need to decide whether the hTable and pTables needs to be a vector or replace it with

    Entry *hTable
    Entry **pTable.

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

Sidebar

Related Questions

I am getting this error: symbol : constructor JTable(float[][],java.lang.String[]) location: class javax.swing.JTable table =
Please consider my codes below: I'm getting an error Constructor on type 'System.String' not
I am getting an error: constructor RedListener in class RedListener cannot be applied to
I am getting the following error: The constructor Intent(new View.OnClickListener(){}, Class<DrinksTwitter>) is undefined In
I'm getting an error: Complex.h|87|error: expected constructor, destructor, or type conversion before '&' token|
I am getting a compile error, saying that the copy constructor of the scoped_ptr
Getting error when I tried like this: $ci =& get_instance(); $ci->db->select(CONCAT_WS(' ',users.name_first,users.name_last) AS user_name,CONCAT_WS('
While mapping class i am getting error 'T' must be a non-abstract type with
All, I'm getting an error with the code below. Here is the error message
I am always getting the error No parameterless constructor defined for this object. when

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.