LinkedList Part

前端 未结 4 1322
小鲜肉
小鲜肉 2021-01-28 12:44

I think I might have done something right, headByRating and headByName both refer to the same address.

I have been drawing diagras working all day trying new things etc,

4条回答
  •  遥遥无期
    2021-01-28 13:13

    If you want to make your List type for experimentation, do it, otherwise use std::list.
    If you want to keep your list sorted while you insert new elements then you have to implement an ordered list.

    It's better to remove "winery field" dependencies from your List. A node should have only one next node, not many. You are making a List, not a Tree.

    // list.h
    struct node
    {
        winery  item;
        node *  next;
    };
    
    class list
    {
        ...
    private:
        node * head;
    };
    

    You can't have one List ordered by different winery fields.
    Make a new type, like CWinery, which will act as a container for your winery records.
    In there, you can have a list to store your elements and methods to sort it or whatever you need.

提交回复
热议问题