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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:42:47+00:00 2026-06-05T07:42:47+00:00

I am struggling with the syntax needed to declare, create, and manipulate a pointer

  • 0

I am struggling with the syntax needed to declare, create, and manipulate a pointer to an array of list objects. I’m creating a hash table template class for a course assignment, using chaining to deal with has collisions.

The way my hash table is supposed to be is an array of list objects. std::list is the only standard library data class I’m allowed to use for the assignment, so vector is out.

My questions are:
How do I declare a pointer to an array of std::list? I have:

private:
    std::list<T> * table;

How do I create the array? I have:

table = new std::list<T>[3]; // start with table size 3

I think I have the declaration and construction right, but I’m not 100% sure. Lastly, how do I interact with the list’s? I’ve got:

    for (int i = 0; i < _tableSize; i++) { // _tableSize is the array's size
        if (!table[0][i].empty()) {
            table[0][i].push_back(thing);
        }
    }

Somehow table[0][i] seems wrong to access a cell of the array that table points to. What should it look like?

  • 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-05T07:42:49+00:00Added an answer on June 5, 2026 at 7:42 am

    Since table is a std::list*, table[i][j] means (table + i)->operator[](j); that is, it calls a member function (with argument j) on the std::list object starting at address table + i.

    It follows that, since std::list doesn’t overload [], table[0][i].empty() is wrong (doubly wrong if T in std::list<T> is such that it hasn’t a member function empty).

    Shortly, I think that what you need is a simple table[list_index_on_array].empty() to check for emptiness.

    Everything else looks ok.

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

Sidebar

Related Questions

I'm struggling with the regular expression syntax needed to simply transform this string: posts/2012-03-16-23-07_an-awesome-post.md
I am struggling pulling a simple list of records from one table object and
I'm struggling to create a list to be displayed on the condition of the
im struggling with syntax here: hopefully this question is v simple, im just miising
I'm brand new to Coffeescript and struggling on the syntax. Can anyone help me
I am struggling to work out the correct MySQL syntax to add the result
What I would like is very simple, but I am struggling with the syntax.
I think I'm having a syntax problem, but I'm struggling to find an answer...
I'm still struggling with this concept. I have two different Person objects, very simply:
I'm struggling with some SQL/php syntax issues here. I'm trying to write two functions.

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.