Skip to the content of the web site.

Lesson 5.4: A simple linked list class

The simple linked list class we described in this course has the class definition

class Linked_list {
    public:
        Linked_list();   // Constructor
       ~Linked_list();   // Destructor

        bool empty() const;
        std::size_t size() const;
        double front() const;
        std::string to_string() const;
        std::size_t find( double const value ) const;
        double operator[]( std::size_t const n ) const;

        void push_front( double const new_value );
        void pop_front();
        void clear();

    private:
        Node *p_list_head_; // Pointer to head node
};

View this simple linked list at repl.it.

The class declarations and definitions are in the corresponding Linked_list.hpp file.