How Do I Create An Array of Linked Lists?

Nov 29, 2016 at 6:23am
Like the title says pretty much. I'm to create an array of linked lists for my homework assignment and would like to know how it's made and how it also works. It also involves me storing the array's index inside of the linked list. This whole task confuses the hell out of me. Examples would be really good, thanks.
Last edited on Nov 29, 2016 at 6:26am
Nov 29, 2016 at 6:31am
Are you using your own class or std::list? The core principle is the same, just like any other data type

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class item
{
    public:
    derived(int const & val): value(new int(val))
    {}

    int const accesor()
    {
        return *value;
    }

    private:
    int * value;
};

int main()
{
    item things[]={item(20),item(30),item(40)};

    std::cout<<things[0].accesor()<<'\n';

    return 0;
}

Nov 29, 2016 at 6:34am
We're using structures in class, our professor actually hasn't taught us about classes or even using std :: list
Nov 29, 2016 at 7:02am
Also to further add to my question, is an array of linked lists basically a hash table?
Topic archived. No new replies allowed.