Search code examples
c++linked-listabstract-data-type

Is there a linked list predefined library in C++?


Is there a linked list in C++ that I could just #include? Or do I need to create my own if I want to use one?


Solution

  • As daniel notes, yes, std::list. Usage would be:

    #include <list>
    // ...
    std::list<int> listOfInts;
    listOfInts.push_back(1);
    // ...
    

    And so on.

    You can find a complete list of STL classes here. The section you're after is 3.2, Container classes. Another useful reference of the C++ Standard Library is here.