简体   繁体   中英

How to have a doubly-linked list point to a string

I am trying to make the .h file for my first assignment after a long break, little rusty with code. All i need to do is make a Node that has a m_next an m_prev and a pointer to a string, i am completely stuck on how you make the pointer to the string, i have always been bad with pointers.

    class DoublyLinkedList
{
public:
    DoublyLinkedList();
    ~DoublyLinkedList();
    bool empty();
    void append(string&);
    void insertBefore(string&);
    void insertAfter(string&);
    void remove(string&);
    void begin();
    void end();
    bool next();
    bool prev();
    bool find(string&);
    const &data getData()
private:
    Class Node
    {
    public:
        Node (string* data, Node *next, Node *prev)
        {m_data = data; m_next = next; m_prev = prev;}
        string m_data;
        Node * m_next;
        Node * m_prev;
    };
    Node *m_head;
    Node *m_tail;
    Node *m_current;
};
#endif // DOUBLYLINKEDLIST_H_INCLUDED

在Node类中将字符串m_data更改为string * m_data

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM