Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 364
user69514 Avatar asked Nov 14 '09 19:11

user69514


People also ask

Can we use linked list in C?

A linked list is a sequence of data structures, which are connected together via links. Linked List is a sequence of links which contains items. Each link contains a connection to another link.

Is linked list predefined in C++?

As daniel notes, yes, std::list . Usage would be: #include <list> // ...

What is linked list in C program?

What is Linked List in C? A Linked List is a linear data structure. Every linked list has two parts, the data section and the address section that holds the address of the next element in the list, which is called a node.


2 Answers

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.

like image 112
GManNickG Avatar answered Sep 29 '22 09:09

GManNickG


#include <list> 
like image 23
Idan K Avatar answered Sep 29 '22 08:09

Idan K