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

user69514 picture user69514 · Nov 14, 2009 · Viewed 41.7k times · Source

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?

Answer

GManNickG picture GManNickG · Nov 14, 2009

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.